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 6 of 6.
Alekhya said:
1 decade ago
Please explain me why we should not use i?
Dinesh.d said:
1 decade ago
Then how can we rectify the linker error?
Sujithra said:
1 decade ago
Why we use sizeof() what purpose to use?
Anunitha said:
2 decades ago
Then how can we rectify da linker error?
Prbaraj said:
8 years ago
Here, int i=20; is the definition.
Raja said:
1 decade ago
How to avoid linker error?
Mounika said:
10 years ago
How can we rectify that?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers