int XX, YY, ZZ; // global variable declarations
void F1(void); // function declaration
void F2(void); // function declaration
void main(void)
{
// local variables in main
int x, y, z;
x = XX; // Ok, XX is in global scope
F1(); // Ok, F1 is in global scope
z = z1; // Error, z1 is local to F1
z = z2; // Error, z2 is local to F2
}
void F1(void)
{
// local variables in F1
int x1, y1, z1;
y1 = YY; // Ok, YY is in global scope
F2(); // Ok, F2 is in global scope
x1 = x; // Error, x is local to main
}
void F2(void)
{
// local variables in F2
int x2, y2, z2;
z2 = ZZ; // Ok, ZZ is in global scope
y2 = y1; // Error, y1 is local to F1
F1(); // Ok, F1 is in global scope
}