Consider the following C program carefully. What will be printed on the screen when this program is compiled and executed?
#include <stdio.h>
int main() {
int x = 0, y = 5;
if (x = y - 5)
printf("Inside if %d", x);
else
printf("Inside else %d", x);
return 0;
}Inside else 0 is printed, because the single = assigns y - 5, which is 0, to x, and 0 is treated as false
Inside if 0 is printed, because the condition compares x with y - 5 and both are equal to 0
The program does not compile, because an assignment is not allowed inside an if condition
Inside else 5 is printed, because x receives the value of y before the condition is tested
The verified answer and full solution are one login away
Every answer here is machine verified, with a step-by-step solution that teaches the method. Your login also unlocks a 7-question mock preview in the real exam interface.
Log in to see the answerMore operators questions