< previous page page_453 next page >

Page 453
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
    Test();
    Test();
    Test();
    return 0;
}

void Test( )
{
    int i = 0;
    static int j = 0;

    i++;
    j++;
    cout << i <<   << j << endl;
}
6. The following function calculates the sum of the numbers from 1 through n. However, it has an unintended side effect. What is it?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
void SumInts( int& n,
              int& sum )
{
    sum = 0;
    while (n >= 1)
    {
      sum = sum + n;
      n = n - 1;
    }
}
7. Given the function heading
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Boolean HighTaxBracket( int inc,
                        int ded )
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
is the following statement a legal call to the function if income and deductions are of type int?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
if (HighTaxBracket(income, deductions))
    cout << Upper Class;
8. The statement
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Power(k, l m);
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
is a call to the void function whose definition is on the next page. Rewrite the function as a value-returning function, then write a function call that assigns the function value to the variable m.

 
< previous page page_453 next page >