Homework H5.2

Problem Homework H5.2 appears below. You will solve Homework H5.2 on paper. Then go to Blackboard, Programs, Homework H5.2 and submit your answer.

Play computer with the program below:

    int y = 1;
    int c = 0;
    while (c<18) {
        c += y;
        int i = 0;
        while (i<3) {
           y += 2;
           i++;
        }
    }
    printf("%d\n", c);
To start playing computer make a row headed by each variable name and below those lines write "screen":
y:
c:
i:

screen:



Now execute the program a statement at a time. If a statement changes a value in a variable, you must write the new value in the appropriate row to the right of the old values. Note that appropriate row for variable x is row x.

If a statement prints something, you must write what is printed in the area BELOW the word "screen". What you put in this area must look like what the program would print on the screen.

If you have any doubts about this go back to the example on the previous page.

next: Function Problems