Quiz 3

CS17

20 pts., Apr. 26

  1. What does the following code fragment print?
    for (int i = 1; i < 30; i *= 2)
       cout << i << endl;
    

    1
    2
    4
    8
    16
    

  2. What does the following code fragment print?
    for (int i = 1; i < 30; i += 3)
    {
       if (i % 2 == 1)   // If i is odd.
          continue;
       else if (i == 10)
          break;
    
       cout << i << endl;
    }
    

    4
    



Thomas P. Kelliher
Wed May 1 08:54:50 EDT 1996
Tom Kelliher