main()

{

extern int i;

i=20;

printf("%d",sizeof(i));

}

Answers were Sorted based on User's Feedback



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

Answer / susie

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.

Is This Answer Correct ?    22 Yes 4 No

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

Answer / sahoo845

This program throws error in compilation. Because variable i is declared but not defined anywhere. Essentially, the variable isn’t allocated any memory. And the program is trying to change the value to 20 of a variable that doesn’t exist at all.

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More C Code Interview Questions

Link list in reverse order.

8 Answers   NetApp,


main() { printf("%d", out); } int out=100;

3 Answers  


main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }

2 Answers   Wipro,


#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }

1 Answers  


writte a c-programm to display smill paces

2 Answers  






main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

1 Answers  


How to count a sum, when the numbers are read from stdin and stored into a structure?

1 Answers  


/*what is the output for*/ void main() { int r; printf("Naveen"); r=printf(); getch(); }

4 Answers  


main() { char a[4]="HELL"; printf("%s",a); }

3 Answers   Wipro,


#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }

1 Answers  


void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }

3 Answers  


{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

4 Answers  


Categories