Interview Question 3571

Created by admin on Sat, 17/11/2012 - 12:39
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 an error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error..
Question: 

main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}

Language: 
Answer: 

Compiler error: undefined symbol out in function main.