C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - Find Output of Program (Q.No. 2)
2.
What will be the output of the program in 16 bit platform (Turbo C under DOS)?
#include<stdio.h>
int main()
{
extern int i;
i = 20;
printf("%d\n", sizeof(i));
return 0;
}
Answer: Option
Explanation:
Linker Error : Undefined symbol 'i'
The statement extern int i specifies to the compiler that the memory for 'i' is allocated in some other program and that address will be given to the current program at the time of linking. But linker finds that no other variable of name 'i' is available in any other program with memory space allocated for it. Hence a linker error has occurred.
The statement extern int i specifies to the compiler that the memory for 'i' is allocated in some other program and that address will be given to the current program at the time of linking. But linker finds that no other variable of name 'i' is available in any other program with memory space allocated for it. Hence a linker error has occurred.
Discussion:
57 comments Page 5 of 6.
Vinu said:
1 decade ago
Explain what is external variables. What is the need of using them?
Shankar said:
10 years ago
I would like to know the exact difference between C, C++ and Java.
Vidya said:
1 decade ago
Rehana output is 4 neither 10 nor 20, anybody explain me briefly.
Batman said:
1 decade ago
i is already defined how can it be said that it is not defined?
Nuzhat said:
1 decade ago
sizeof(i) n here i is int so int size is 2 bytes in 16-bit.
Sai lakshmi said:
9 years ago
What is extern variable, how it work? please explain!
Rahul juyal said:
1 decade ago
Because in the sameer program we declare int a=20;
Vamsibhargavi said:
1 decade ago
Please explain in other way. I didn't get this.
Sharmila said:
1 decade ago
How can the output be 2 in jenish's program?
Vikas said:
1 decade ago
please explain me, what is the mean of s*=3;
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers