The output of the code below is
#include <stdio.h>
int x;
void main()
{
if (x)
printf("hi");
else
printf("how are u");
}
Answer: B
Correct answer: how are u
x is declared at file scope, so it has static storage duration and is zero-initialised - not left holding junk, as an uninitialised local would be. The condition is therefore false and the else branch runs.
Please log in or register to report this question.