What is the output of this C code?
void main()
{
static int x;
printf("x is %d", x);
}
Answer: D
Correct answer: 0
A static variable, whether at file scope or inside a function, is zero-initialised if given no initialiser. So it prints 0 - unlike an ordinary automatic variable, which would hold junk.
Please log in or register to report this question.