int main(){extern int x;x=13;printf("%d",x);return

int main()
{
extern int x;
x=13;
printf("%d",x);
return 0;} what is the o/p?

a)13, b)vary from compiler c)linker error d)undefined symbol.

3Comments
Arvind Rawat @arvind.rawat
16 Dec 2014 01:13 pm

It will give compiler error : "undefined symbol".

This is because when we write

                                extern int x;

it means we have declared an extern variable 'x', but we have not defined it. And when a variable is not defined in a program, then no memory is allocated to it, so when we try to access the value of that variable (x), the compiler will throw error : "undefined symbol".

Swatish Satheesan @swatishsathe
16 Dec 2014 01:50 pm
It will be a linker error ryt? Because the extern keyword will tell the compiler that the variable x is defined in some other file and to wait until link time to resolve it..
Bhupathi Vaibhav @kiranvaibhav
16 Dec 2014 01:53 pm

Ya right sathe Tan Q

Pages