As you notice in the next example x defined one time globally then used in function() and main().
Example :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| #include <stdio.h>
#include <stdlib.h>
int x=0;
int function (){
x++;
return x;
}
int main()
{
function () ;
printf("X=%d",x);
return 0;
}
|
Ouptut :
Local Variables :
0 Comment to "Variable Scope "
Post a Comment