What will be the output of the program?
#include <stdio.h>
int main()
{
int a = 300, b, c;
if(a >= 400)
b = 300;
c = 200;
printf("%d, %d, %d\n", a, b, c);
return 0;
}
Answer: C
Correct answer: 300, Garbage, 200
The condition \(300 \ge 400\) is false, so b = 300 never runs - and b, an uninitialised automatic variable, holds whatever was on the stack. c = 200 is a separate statement outside the if, so it always executes.
Please log in or register to report this question.