1. // moreCalls.cpp
 2. 
 3. #include <iostream>
 4. 
 5. using namespace std;
 6. 
 7. // Function prototypes:
 8. int first (int);
 9. void second (int&);
10. void third (int);
11. 
12. 
13. int main ()
14. {
15.    int i = 10;
16.    cout << "Line 16: main begins:          i = " << i << endl;
17.    i = first( i );
18.    cout << "Line 18: main ends:            i = " << i << endl;
19.    return 0;
20. }  // function main
21. 
22. 
23. int first ( int j )
24. {
25.    cout << "Line 25: first begins:         j = " << j << endl;
26.    if ( j % 3 == 2 )
27.       j++;
28.    else
29.       j--;
30.    cout << "Line 30: first calls second:   j = " << j << endl;
31.    second( j );
32.    cout << "Line 32: first calls third:    j = " << j << endl;
33.    third( j );
34.    cout << "Line 34: first ends:           j = " << j << endl;
35.    return( j+1 );
36. }  // function first
37. 
38. 
39. void second ( int& k )
40. {
41.    cout << "Line 41: second begins:        k = " << k << endl;
42.    k = k + 4 * 2;
43.    cout << "Line 43: second calls third:   k = " << k << endl;
44.    third( k );
45.    cout << "Line 45: second ends:          k = " << k << endl;
46. }  // function second
47. 
48. 
49. void third ( int n )
50. {
51.    cout << "Line 51: third begins:         n = " << n << endl;
52.    int i = 0;
53.    while ( i <= 3 ) {
54.       for ( int j = 0; j < i; j++ ) {
55.          n++;
56.       } // for j
57.       i++;
58.    } // while i
59.    cout << "Line 59: third ends:           n = " << n << endl;
60. }  // function third