Held: Tuesday, February 17, 1998
while Loop
while loop, which has
the form
while (test)
{
statements;
} // while
while loop
called the do loop, and has the form
do
{
statements
} while (test);
See loops in in computing exercise 5 for an example and some exercises.
for loop
for (initialization; test; increment)
{
statement;
} // for
initialization;
while (test)
{
statement;
increment;
} // while (test)
for loop can be omitted
(in which case it is ignored).
int i; // A counter variable
int factorial; // The factorial of N
factorial = 1;
for (i = 1; i <= N; i = i+1)
{
factorial = factorial * i;
} // for
var++.
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Thu May 7 10:53:52 1998.
This page generated on Thu May 7 10:58:48 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu