be
// Define 2 glogbal variables int g1 = 10; // Global variables can be any data int g2 = 20; // type just as local variables can ^ First locsi created
{ void main() int 11 = 14;^ clrscr();
// the next linę shows that globals are available cout « "At the top of main(), \n";
cout « "The globals are " «gl « " and " « g2 « ' \n'; cout « "The local variable 11 is "<<11<<'\n';
//
Create a new błock
int 12 = 21; // Local to this błock only cout « "\nln main()'s inner błock, the globals are";Tbe cout«" "«gl«" and "«g2 «'\nl; // Still available cout « "The local variable 11 is " « 11 « '\n'; inner
cout « "The local variable 12 is " « 12 « '\n'; błock
cout « "(11 is about to disappear...)\n\n";
// This terminates all valid use of 12
cout « "Towards the end of main, the globals are"; cout« ' '«gl«" and "«g2«'\n//Still available cout « "The local variable 11 is " « 11 « ’\n'; cout « "The local 12 is no longer valid.\n";
return;
// All variables go away now