Sail E0 Webinar
Question
What is the output of this C code?
int main()
{
printf("Hello World! %d \n", x);
return 0;
}
Options:
A .  Hello World! x;
B .  Hello World! followed by a junk value
C .  Compile time error
D .  Hello World!
Answer: Option C


It results in an error since x is used without declaring the variable x.
Output:
$ cc pgm1.c
pgm1.c: In function 'main':
pgm1.c:4: error: 'x' undeclared (first use in this function)
pgm1.c:4: error: (Each undeclared identifier is reported only once
pgm1.c:4: error: for each function it appears in.)



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers