C++ Book


Exercises

  1. Rewrite the Menu Chooser program from this chapter using an enumeration to represent difficulty levels. The variable ‘choice’ will still be of type ‘int’.

  2. What’s wrong with the following loop?

1
2
3
4
5
6
int x = 0;
while (x)
{
    ++x;
    cout << x << endl;
}
  1. Write a new verion of the Guess My Number program in which the player and the computer switch roles. That is, the player picks a number and the computer must guess what it is.