Advertisement
Taraxacum

VariableScope

Oct 24th, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a = 10;
  6.  
  7. int main(int argc, char const *argv[])
  8. {
  9.     cout << __LINE__ << "\t" << a << endl;
  10.  
  11.     for (int i = 0; i < 5; ++i)
  12.     {
  13.         cout << __LINE__ << "\t" << a << endl;
  14.         int a = 3;
  15.         cout << __LINE__ << "\t" << a << endl;
  16.     }
  17.  
  18.     cout << __LINE__ << "\t" << a << endl;
  19.     int a = 8;
  20.  
  21.     cout << __LINE__ << "\t" << a << endl;
  22.  
  23.     if (a > 9) {
  24.         int a = 20;
  25.         cout << __LINE__ << "\t" << a << endl;
  26.     } else {
  27.         int a = 30;
  28.         cout << __LINE__ << "\t" << a << endl;
  29.     }
  30.  
  31.     cout << __LINE__ << "\t" << a << endl;
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement