Learn C MCQs

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

Which of the following is used to read a character from standard input in C?

1) getchar()

2) readchar()

3) scanf()

4) getInput()

Answer : Option 1

What is the purpose of the `static` keyword?

1) To define a global variable

2) To limit variable scope

3) To allocate dynamic memory

4) None of the above

Answer : Option 2

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

1) 17

2) 15

3) 13

4) 20

Answer : Option 1

Which of the following operators is used to access the members of a structure?

1) .

2) ->

3) ::

4) Both 1 and 2

Answer : Option 4

What is the output of printf("%d", 5 < 4 && 3 > 2);?

1) 1

2) 0

3) 5

4) 4

Answer : Option 2

What is the correct way to declare a function that takes an integer and returns a float?

1) float func(int);

2) int func(float);

3) float func(int x);

4) Both 1 and 3

Answer : Option 4

Which of the following is the correct way to define a union?

1) union name { int x; float y; };

2) union { int x; float y; };

3) Both 1 and 2

4) None of the above

Answer : Option 1

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

1) 1

2) 2

3) 3

4) 4

Answer : Option 1

Which of the following can be used to terminate a loop in C?

1) break

2) exit

3) return

4) stop

Answer : Option 1

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

1) 14

2) 13

3) 12

4) 10

Answer : Option 1