// // Filename: pgm3_4a.cpp // // Description: Demo program, Scope #1: Global, Local and Block Scope // // ENSC 104: Digital Computer Programming // // Instructor: Dr. Walsh // // Section: 2 // // Date Created: 03/17/98 // Last Modified: 03/17/98 // // Name: N/A // #include void sub( void ); int x = 1; // global variable int y = -1; // global variable main() { cout << "X = " << x << ", Y = " << y << endl; int x = 5; // local variable to main cout << "X = " << x << ", Y = " << y << endl; { // Block A int x = 10; // variable local to block A cout << "X = " << x << ", Y = " << y << endl; { // Block B int x = 15; // variable local to block B cout << "X = " << x << ", Y = " << y << endl; { // Block C int x = 20; int y = -20; cout << "X = " << x << ", Y = " << y << endl; sub(); } // End Block C sub(); } // End Block B cout << "X = " << x << ", Y = " << y << endl; } // End Block A cout << "X = " << x << ", Y = " << y << endl; return 0; } // End Main void sub( void ) { cout << "*** Inside sub(), X = " << x << endl; }