Learn C MCQs

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

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

1) 0

2) 1

3) 3

4) 2

Answer : Option 2

Which of the following functions can be used to convert an integer to a string in C?

1) itoa()

2) str()

3) convert()

4) intToStr()

Answer : Option 1

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

1) 4

2) 8

3) 16

4) 2

Answer : Option 2

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

1) #define PI 3.14

2) const float PI = 3.14;

3) float PI = 3.14;

4) Both 1 and 2

Answer : Option 4

Which of the following is the correct way to declare a function with an array as a parameter?

1) void func(int arr[]);

2) void func(int arr{});

3) void func(int arr);

4) void func(int arr*);

Answer : Option 1

Which of the following is not a logical operator in C?

1) &&

2) ||

3) !

4) %

Answer : Option 4

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

1) 2

2) 1

3) 3

4) 0

Answer : Option 1

Which of the following functions is used to open a file in C?

1) open()

2) fopen()

3) fileopen()

4) None of the above

Answer : Option 2

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

1) 25

2) 20

3) 15

4) 5

Answer : Option 1

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

1) const int x = 10;

2) int const x = 10;

3) const x = 10;

4) Both 1 and 2

Answer : Option 4