Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is the correct syntax for a for loop?
1) for (initialization; condition; increment) {}
2) for {} (initialization; condition; increment)
3) for (condition; initialization; increment) {}
4) for (initialization, condition, increment) {}
Answer : for (initialization; condition; increment) {}
What is the output of printf("%d", 5 | 2);?
1) 3
2) 7
3) 5
4) 1
Answer : 7
Which of the following functions is used to copy a string in C?
1) strcpy()
2) strcat()
3) strlen()
4) strcmp()
Answer : strcpy()
What is the output of printf("%d", 10 && 0);?
1) 1
2) 0
3) 10
4) 5
Answer : Option 2
Which of the following is the correct way to define a prototype for a function?
1) void func();
2) void func(int);
3) int func();
4) All of the above
Answer : All of the above
What is the output of printf("%d", 3 + 4 * 5);?
1) 35
2) 27
3) 23
4) 43
Answer : 23
Which of the following is a valid floating-point literal in C?
1) 3.14
2) 3.14f
3) 3.14e2
4) All of the above
Answer : All of the above
What is the output of printf("%d", 5 < 3);?
1) 1
2) 0
3) 5
4) 3
Answer : Option 2
Which of the following keywords is used to define a constant in C?
1) const
2) define
3) static
4) final
Answer : const
What is the output of printf("%d", 9 & 5);?
1) 1
2) 5
3) 9
4) 13
Answer : 1