C Programming · Question 10 · Medium
What will be the output of the following C program?
#include <stdio.h>
int main(void) {
int a = 0, b = 5;
if (a && ++b)
printf("yes ");
printf("%d", b);
return 0;
}
- 6
- yes 5
- yes 6
- 5
Answer and explanation
Answer: D. 5
Explanation: a is 0, so a && ++b short-circuits: ++b is never evaluated and the condition is false. Nothing is printed by the if, and b stays 5.
Previous: What will be the output of the following C program? · Next: What will be the output of the following C program?
Practise c programming
Try a fresh set of c programming questions with an explanation after every answer, free and without signing up: C Programming practice. Or sit a full placement mock test.
More c programming questions
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
More technical & programming practice
Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge