Learn C MCQs

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

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

1) #define PI 3.14

2) const int PI = 3.14;

3) Both 1 and 2

4) Neither 1 nor 2

Answer : Option 3

What is the output of printf("%d", 10 % 3);?

1) 3

2) 2

3) 1

4) 0

Answer : Option 3

What does the `scanf()` function do?

1) Reads input from the user

2) Prints output to the screen

3) Reads a file

4) Writes to a file

Answer : Option 1

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

1) 16

2) 14

3) 12

4) 10

Answer : Option 1

Which of the following is a logical operator in C?

1) &&

2) ||

3) !

4) All of the above

Answer : Option 4

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

1) 0

2) 5

3) 10

4) 20

Answer : Option 1

Which of the following is used to define a macro in C?

1) #define

2) const

3) enum

4) typedef

Answer : Option 1

What is the output of printf("%d", 8 & 3);?

1) 2

2) 3

3) 8

4) 1

Answer : Option 4

Which of the following is a valid variable name in C?

1) 1stNumber

2) number$

3) _number

4) number-name

Answer : Option 3

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

1) 1

2) 0

3) 10

4) 5

Answer : Option 2