1
2
3
4
5
6
| main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
} |
main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}
Click here to view the answer
Answer:
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 an error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.