Chapter 4 Exercise Set 0: Chapter Review

  1. What happens if you call the countdown function introduced in the Recursion section with an argument that is a negative number?

  2. Draw a stack diagram for n_lines, invoked with the parameter n equal to 4.

  3. Write a function named compare that takes two int arguments, a and b, and prints out whether a is greater than b, a is less than b, or a is equal to b.

Random numbers revisisted

  1. Now that you know about the Modulus operator, use it to generate 3 random numbers between 1 and 10. This is a common algorithm, so do a web search for it if you need help figuring it out.

Bitwise operators

  1. What would be output by the following code snippet?

    unsigned char b = 23;
    cout << (b | 15) << endl;