Next: Exercises Up: The do-while statement Previous: Multiple Choice Questions

Review Questions

  1. What is the major difference between a while statement and a do-while statement?
  2. What would be output by the following segment of C++?
    int i;
    i = -12;
    do
      {
        cout << i << endl;
        i = i - 1;
      }
    while (i > 0)
    

  3. Do questions 3 and 4 of Lesson 16 again using a do-while statement. What would be the difference from your solution using a while statement in the case where n is zero?



Next: Exercises Up: The do-while statement Previous: Multiple Choice Questions