1: //scope6.cpp 2: //A nonsense program to test your understanding 3: //of variable scope and lifetime. 5: #include <iostream> 6: using namespace std; 8: int j = 3; //Global variable 10: void DoThis(int& i, int j) 11: { 12: i = 3 * j; 13: j = 4 * i; 14: cout << i << " " << j << endl; 15: } 17: int i = 2; //Global variable 19: void DoThat(int& i) 20: { 21: j = 2 * i; 22: i = j % 3; 23: cout << i << " " << j << endl; 24: } 26: int main() 27: { 28: cout << endl; 29: cin >> i >> j; 30: DoThat(i); 31: DoThis(j,i); 32: cout << i << " " << j << endl; 33: }