Skip to content

C++ Program to Demonstrate Scope Regulator Operator

C++ Program to Demonstrate Scope Regulator Operator

Code:

/*C++ Program to Demonstrate Scope Regulator Operator*/
#include<iostream.h>
#include<conio.h>
int m=10; //global m
int main()
{
 int m=20;  //m redeclared. local to main
 clrscr();
 {
 int k=m;
 int m=30; //m declared agan local to inner block
 cout<<“n we are in inner block n”;
 cout<<” value of k = “<<k<<endl;
 cout<<” value of m = “<<m<<endl;
 cout<<” value of ::m= “<<::m<<endl;
 }
 cout<<“n we are in outer block n”;
 cout<<” value  of m=”<<m<<“n”;
 cout<<” value of ::m= “<<::m <<“n”;
 getch();
 return 0;
 }


Sample Output:

Comment bellow for your Query and Feedback

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!