UP | HOME

HW15
COP-3223H

  1. Take the following program:

    int i = 1;
    while (i < 10) {
      printf("%d\n", i);
      i = i + 1;
    }
    

    Using only your mind and/or pencil and paper (do not compile and run the program, what will be the output of running this program? How many times will printf be called in this program?

  2. Take the following program:

    int i = 0;
    int sum = 0;
    while (i < 10) {
      int j = 0;
      while (j < 5) {
        j = j + 1;
        sum = sum + 2;
      }
      i = i + 1;
    }
    printf("%d\n", sum);
    

    Using only your mind and/or pencil and paper (do not compile and run the program, what will be the output of this program? How many times does each while loop run?

Enter your answers into webcourses.

Author: Paul Gazzillo

Created: 2026-02-17 Tue 19:38

Validate