Return To COSI 216 -  Home
Return To Course Outline
Loops:

Example of a loop controlled by sequences    Re-write into loops

Definition of an array

Move from while loop to for loop      Taking a Quiz

Fixed number of repetition:   (for loop)
   Before the program is created, the number times of repeating is known.
Non fixed number of repetition: (while loop)

     Before the program is created, the number times of repeating is unknown.
         The user make the decision when to terminate programs.
for (counter =initial value; test expression; increment/decrement counter)
{
     Statement1;
     Statement2;
     ....
     ....
}
while (test expression)
{
     Statement1;
     Statement2;
     ....
     Update test condition
}
do
{
     Statement1;
     Statement2;
     ....
     ....
}
while (test expression);
Example of for loop                 Applications Example of while loop  

Repeat it until user say "no more repeating"                                        Exercises from the textbook

What is different between while loop and do-while loop                             Example of using loops for an array       

Break and Continue Options               A test sample                      Nested loop         How to read a data file     Data File 2

Example of using a while loop to read a data file

Last Version  Bubble Sort ( Flowchart Example  Codes