Program to illustrate the Nested & Parallel scopes


     # include <iostream.h>
    
    int x =11;                    // Global Declaration. 'x' is global variable.
    int main( )
     {       
    int x = 22;
    {         //begin scope of internal block
                 int x =33;
                 cout<<"In block inside main( ) : x =  "<<x << endl ;
    }       //end scope of internal block
    cout<<"In main( ) : x =  "<<x <<endl;
    cout<<"In main( ) :   ::x =  "<<::x <<endl;
                  return 0;
      }                               //end scope of main( )

No comments:

Post a Comment