Learn C MCQs

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

What is the output of printf("%d", 8 >> 2);?

1) 4

2) 2

3) 1

4) 8

Answer : Option 2

Which of the following is used to find the absolute value of an integer in C?

1) abs()

2) fabs()

3) absval()

4) absint()

Answer : Option 1

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

1) 6

2) 5

3) 2

4) 4

Answer : Option 1

What is the output of printf("%d", 5 && 6);?

1) 1

2) 0

3) 5

4) 6

Answer : Option 1

Which of the following is the correct syntax for an if statement in C?

1) if (condition) {}

2) if condition {}

3) if {condition}

4) Both 1 and 2

Answer : Option 1

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

1) 17

2) 16

3) 14

4) 12

Answer : Option 1

Which of the following is the correct way to declare a pointer to a function in C?

1) int (*func_ptr)();

2) int *func_ptr();

3) void func_ptr();

4) void *func_ptr();

Answer : Option 1

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

1) 15

2) 14

3) 16

4) 13

Answer : Option 1

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

1) for

2) while

3) do-while

4) foreach

Answer : Option 4

What is the purpose of the `default` keyword in a switch statement?

1) To handle unhandled cases

2) To define a default case

3) To terminate the switch

4) None of the above

Answer : Option 1