Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Why does one work and other does not.... (http://www.go4expert.com/forums/why-does-one-work-and-other-does-not-t6651/)

An007kit 2Oct2007 23:41

Why does one work and other does not....
 
These are the two codes...
a)
Code:

#include<stdio.h>
int i=5;
void main()
{
int i=6;
printf("%d",i);
}

output = 6
b)
Code:

#include<stdio.h>
void main()
{
extern int i;
int i=6
printf("%d",i);
}
int i=5;

output=ERROR

DaWei 3Oct2007 01:22

Re: Why does one work and other does not....
 
Read up on scope. Learn to put your code in code tags.


All times are GMT +5.5. The time now is 20:38.