Sail E0 Webinar
Question
What is the output of this C code?
int main()
{
int y = 10000;
int y = 34;
printf("Hello World! %d\n", y);
return 0;
}
Options:
A .  Compile time error
B .  Hello World! 34
Answer: Option A


Since y is already defined, redefining it results in an error.
Output:
$ cc pgm2.c
pgm2.c: In function 'main':
pgm2.c:5: error: redefinition of 'y'
pgm2.c:4: note: previous definition of 'y' was here



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers