fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int x =5;
  7. {
  8. cout<<"Before Variable in the Local scope "<<x<<endl;
  9. int x =10;
  10. cout<<"After in the local scope "<<x<<endl;
  11. }
  12. cout<<endl;
  13. cout<<"Printing in the global scope "<<x<<endl;
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Before Variable in the Local scope 5
After in the local scope 10

Printing in the global scope 5