I have declared variable a global variable in first program and static global variable in second program. What is difference between global and static global variable ? Where they both are different in scope or life time of variable ?
C:
#include <stdio.h>
/* global variable declaration */
int a = 20;
int main () {
/* local variable declaration in main function */
int b = 10;
printf ("value of a = %d\n", a);
printf ("value of b = %d\n", b);
return 0;
}
C:
#include <stdio.h>
/* global variable declaration */
static int a = 20;
int main () {
/* local variable declaration in main function */
int b = 10;
printf ("value of a = %d\n", a);
printf ("value of b = %d\n", b);
return 0;
}