1: //scope5.cpp
2: //A nonsense program to test your understanding
3: //of variable scope and lifetime.
5: #include <iostream>
6: using namespace std;
8: int i, j, k, t; //Global variables
10: void DoSomething(int i, int j)
11: {
12: int t; //Local to "DoSomething"
14: t = i;
15: i = j;
16: j = t;
17: cout << i << j << k << t << endl;
18: }
20: int main()
21: {
22: cout << endl;
23: i = 1; j = 2; k = 3; t = 4;
24: cout << i << j << k << t << endl;
25: DoSomething(i, j);
26: cout << i << j << k << t << endl;
27: }