Question 1
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int x = 0, y = 10;
if (x && ++y)
y++;
printf("%d", y);
return 0;
}Detailed Solution
In a logical AND expression (x && ++y), the left operand evaluates to 0. Due to short-circuit evaluation, ++y is skipped entirely, leaving y as 10.