Skip to main content

PDF TEST

Write a CPP program which explains use of Scope Resolution Operator...

Output Shown Below The Code!


  1. #include<iostream>  
  2. using namespace std;  
  3. //Global Variables 
  4. int x=10;  
  5. main ()  
  6. {  
  7. //Local Variables
  8. int x=20;  

  9. // printing the value of the local variables  
  10. cout<<"The value of the local x: "<<x;  
  11.   
  12. /**using scope resolution operator (::)
  13. to access the global variables**/   
  14. cout<<"\nThe value of the global variable x: "<<::x;   

  15. return 0;  
  16. }  

Output:


Comments