Learn C MCQs

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

Which of the following is a correct way to define a constant in C?

1) const int x = 10;

2) #define x 10

3) int const x = 10;

4) All of the above

Answer : Option 4

What will be the output of printf("%d", 10 - 3 * 2);?

1) 4

2) 1

3) 5

4) 2

Answer : Option 1

Which of the following correctly declares a union?

1) union name {int a; float b;};

2) union {int a;};

3) union name();

4) None of the above

Answer : Option 1

What is the correct syntax to declare a multi-dimensional array in C?

1) int arr[2][3];

2) int arr[3,2];

3) int arr(2)(3);

4) None of the above

Answer : Option 1

What will be the output of printf("%d", 2 << 2);?

1) 8

2) 4

3) 2

4) 16

Answer : Option 1

Which of the following correctly represents a character array in C?

1) char str[10];

2) char str();

3) char str = "Hello";

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

Answer : Option 1

What is the output of printf("%d", 7 && 1);?

1) 0

2) 1

3) 7

4) Error

Answer : Option 2

Which of the following is used to terminate a string in C?

1) NULL

2) 0

3) End

4) None of the above

Answer : Option 1

What will be the output of printf("%d", 6 >> 1);?

1) 3

2) 6

3) 12

4) 2

Answer : Option 1

Which of the following is true regarding the `switch` statement in C?

1) It can have multiple case labels.

2) It can have an optional default case.

3) The case labels must be constant expressions.

4) All of the above

Answer : Option 4