Learn C MCQs

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

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

1) 5

2) 10

3) 2

4) 1

Answer : Option 1

Which of the following can be used to read a string from standard input in C?

1) scanf()

2) getchar()

3) fgets()

4) All of the above

Answer : Option 4

What is the correct syntax to declare a function that takes no parameters?

1) void func()

2) func() {}

3) void func() {}

4) Both 1 and 3

Answer : Option 4

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

1) #define

2) const

3) macro

4) define

Answer : Option 1

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

1) 1

2) 2

3) 0

4) 3

Answer : Option 1

Which of the following is a looping structure in C?

1) for

2) while

3) do-while

4) All of the above

Answer : Option 4

What is the purpose of the `return` statement in C?

1) To return a value from a function

2) To exit a loop

3) To stop the program

4) None of the above

Answer : Option 1

Which of the following is not a keyword in C?

1) goto

2) return

3) const

4) function

Answer : Option 4

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

1) 10

2) 8

3) 20

4) 12

Answer : Option 1

What is the purpose of the `sizeof` operator?

1) To determine the size of a variable

2) To count the number of elements in an array

3) To allocate memory

4) None of the above

Answer : Option 1