Algorithm 7

Set-up instructions:

  1. Draw six adjacent boxes and number the boxes 0 though 5
  2. Put the following numbers in boxes 0 - 5, one number per box: 3 7 14 9 7 2

Carry out the following instructions using the values in the group of numbered boxes.

  1. Draw a line that values may be written on, label the line Output
  2. Draw a box, label the box I, write the number 0 in box I
  3. Draw a box, label the box S, write the number 0 in box S
  4. If the number in box I is less than 6 then do the next instruction, otherwise do instruction 8
  5. Replace the number in box S with the value currently in box S plus the number in the numbered box whose number is the same as the number in box I
  6. Replace the number in box I with the number that is one more than the number currently in box I
  7. Go back and do instruction 4 again
  8. Write the number in box S on the line labeled Output
  9. You are done

Describe the significance of the number on the Output line.

Describe the value in box S after each execution of instruction 5.

What would happen if the number 6 was replaced by 7 in instruction 4?