Learn C MCQs

Prepare C MCQs (Multiple choice Questions) for exam and job interviews.

Which of the following is a correct way to declare a multi-dimensional array?

1) int arr[2][3];

2) int arr[3,2];

3) int arr(2)(3);

4) None of the above

Answer : int arr[2][3];

What is the correct syntax to declare a function in C?

1) void func()

2) void func;

3) func void()

4) function()

Answer : void func()

Which of the following is the correct way to initialize a string in C?

1) char str[] = "Hello";

2) char str = "Hello";

3) char str[5] = "Hello";

4) char str(5) = "Hello";

Answer : char str[] = "Hello";

What will be the output of printf("%d", 4 ^ 5);?

1) 1

2) 9

3) 4

4) 5

Answer : 1

Which of the following statements is true about pointers?

1) Pointers can point to any data type.

2) Pointers can be assigned NULL.

3) Pointers can be incremented.

4) All of the above

Answer : All of the above

What is the output of printf("%d", 3 * 4 + 5);?

1) 12

2) 17

3) 15

4) 14

Answer : 17

Which of the following functions can be used to concatenate two strings in C?

1) strcat()

2) concat()

3) strjoin()

4) strcombine()

Answer : strcat()

What is the correct way to declare a structure in C?

1) struct {int a;};

2) struct name {int a;};

3) structure {int a;};

4) struct name;

Answer : struct name {int a;};

Which of the following is not a data type in C?

1) float

2) int

3) decimal

4) char

Answer : decimal

What will be the output of printf("%d", 10 && 0);?

1) 1

2) 0

3) 10

4) Error

Answer : Option 2