Site hosted by Angelfire.com: Build your free website today!
While and Do While Loops


A while loop is similiar to a for loop but better suited for multiple loops. In a while loop, something inside the loop triggers the loop to stop.

Logical Operators:
Operator Meaning
! Logical inverse
&& Logical AND
== Logical OR
!= Inequality
There are two kinds of while loops:

the standard while loop

The while loop repeats a statement or group of statements as long as a control expression is true. Unlike a for loop, a while loop doesn't use a counter variable.
A while loop doesn't use a counter variable. The control expression in a while loop can be any valid expression.

the do while loop

The do while loop repeats a statement or group of statements as long as a control expression is true at the end of the loop.
Because the control expression is tested at the end of the loop, a do while loop is executed at least one time.

A do while loop repeats the expression at the begining of the loop.
The != symbol shows an inequality.