Saturday, 24 August 2013


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

Related Posts :



0 comments:

Confused? Feel free to ask

Post a Comment