C - Data Types - Discussion

You Are Here :: Home > C > Data Types - Discussion

 



Q.

What will be output of following program?

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

A. 0 B. 20
C. 20 D. Linker error

Answer: Option D
Explaination:

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.



Discussion

Your Comments Goes here...
NameDiscussion