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 : 5

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 : All of the above

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 : Both 1 and 3

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

1) #define

2) const

3) macro

4) define

Answer : #define

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

1) 1

2) 2

3) 0

4) 3

Answer : 1

Which of the following is a looping structure in C?

1) for

2) while

3) do-while

4) All of the above

Answer : All of the above

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 : To return a value from a function

Which of the following is not a keyword in C?

1) goto

2) return

3) const

4) function

Answer : function

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

1) 10

2) 8

3) 20

4) 12

Answer : 10

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 : To determine the size of a variable