Sunday, January 22, 2012

Extern Concepts

1.int main()
{
int i=20;
extern int i;
printf("%d",i);
getch();
return 0;
}
Output:20
2. .int main()
{
extern int i;
int i=20;
printf("%d",i);
getch();
return 0;
}
Output:Compiler Error--In function main redeclaration of int i-int i previously declared here.
3. .int main()
{
extern int i;
i=20;
printf("%d",i);
getch();
return 0;
}
Output:Compiler Error-Undefined reference to i
4.int main()
{
extern int i=80;
printf("%d",i);
getch();
return 0;
}
Output:Compiler Error-i has both extern and initializer
5.int main()
{
extern int i;
printf("%d",i);
getch();
return 0;
}
int i=20;
Output:20

No comments:

Post a Comment