Skip to main content

Section 3.2 WriteLoops-Exercise

Subgoals for Writing a Loop.

  1. Determine purpose of loop
    1. Pick a loop structure (while, for, do_while)
  2. Define and initialize variables
  3. Determine termination condition
    1. Invert termination condition to continuation condition
  4. Write the loop body
    1. Update Loop Control Variable to reach termination

Exercises Exercises

1.

Fill in the blanks in the following code to create a program that will print the prime numbers between 1 and 100 (inclusive).
You have attempted of activities on this page.