Determine output:
void main()
{
extern int i;
i=20;
printf("%d", sizeof(i));
}
void main()
{
extern int i;
i=20;
printf("%d", sizeof(i));
}
A. 20
B. 2
C. Compiler Error
D. Linker Error
Answer: Option D
Solution(By Examveda Team)
Linker error: undefined symbol '_i'. Explanation:
extern declaration specifies that the variable i is defined somewhere else. The compiler passes the external variable to be resolved by the linker. So compiler doesn't find any error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.
Join The Discussion
Comments ( 1 )
Determine output:
void main()
{
int const *p=5;
printf("%d", ++(*p));
}
A. 6
B. 5
C. Garbage Value
D. Compiler Error
A. mmm nnn aaa
B. mmmm nnnn aaaa
C. Compiler Error
D. None of These
A. I hate Examveda
B. I love Examveda
C. Error
D. None of These
Determine Output:
void main()
{
static int var = 5;
printf("%d ", var--);
if(var)
main();
}
A. 5 5 5 5 5
B. 5 4 3 2 1
C. Infinite Loop
D. None of These
can you please explain me in the above question, why it is not seeking any compilation error??