Chapter 4 Exercise Set 0: Chapter Review¶
What happens if you call the
countdownfunction introduced in the Recursion section with an argument that is a negative number?Draw a stack diagram for
n_lines, invoked with the parameternequal to4.Write a function named
comparethat takes twointarguments,aandb, and prints out whetherais greater thanb,ais less thanb, orais equal tob.
Random numbers revisisted¶
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¶
What would be output by the following code snippet?
unsigned char b = 23; cout << (b | 15) << endl;