Code for ILLUSTRATION OF PROPERTIES OF GLOBAL VARIABLES in C Programming
int fun1(void);
int fun2(void);
int fun3(void);
int x ; /* global */
main( )
{
x = 10 ; /* global x */
printf("x = %d\n", x);
printf("x = %d\n", fun1());
printf("x = %d\n", fun2());
printf("x = %d\n", fun3());
}
fun1(void)
{
x = x + 10 ;
}
int fun2(void)
{
int x ; /* local */
x = 1 ;
return (x);
}
fun3(void)
{
x = x + 10 ; /* global x */
}
Output x = 10
x = 20
x = 1
x = 30