#include<iostream>
using namespace std;
int x = 10; //global x
int main()
{
int x = 15;
{
int p = x;
int x = 20;
cout<<"In the first loop \n";
cout<<"p = "<<p<<"\n";
cout<<"x = "<<x<<"\n";
cout<<"::x = "<< ::x<<"\n";
}
cout<<"\nIn the second loop \n";
cout<<"x = "<<x<<endl;
cout<<"::x = "<<::x<<"\n";
return 0;
}
OUTPUT:
using namespace std;
int x = 10; //global x
int main()
{
int x = 15;
{
int p = x;
int x = 20;
cout<<"In the first loop \n";
cout<<"p = "<<p<<"\n";
cout<<"x = "<<x<<"\n";
cout<<"::x = "<< ::x<<"\n";
}
cout<<"\nIn the second loop \n";
cout<<"x = "<<x<<endl;
cout<<"::x = "<<::x<<"\n";
return 0;
}
OUTPUT:
No comments:
Post a Comment