CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

Do it while...

executes and repeats a statement while a condition is true

do
{
<statement>
}
while ( <expression> );
 
  • <statement> is executed at least once;
  • <statement> may be a compound;
  • <expression> is checked after each loop iteration;
Example:
 

void jumpjack(athlete somebody, int howmany)

{

int count=1;
do
{
somebody.ready();
somebody.up();
somebody.ready();
}
while (++count<=howmany);

}