Chapter 7 Exercises

  1. Write C++ code to output a count down, as shown below:
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    0
    Blast off!
  2. Given the following code, what do you think is displayed? Execute the code. What was displayed?
    for( int count = 0; count < 5; count++){
        cout << '*';
    }
    cout << endl;
  3. Given the following code, what do you think is displayed? Execute the code. What was displayed?
    for( int count = 0; count < 5; count++);
    {
        cout << '*';
    }
    cout << endl;
  4. Write C++ code to output a rectangle of *s. Ask the user for the width and length. For example:
    I'm going to display a rectangle of *s for you.
    Please enter the length: 5
    Please enter the width: 3
    	    
    *****
    *****
    *****