do {
statement(s);
} while ( condition );
_____________________An example_____________________
do {
num.Text = counter;
counter = counter + 1;
} while ( counter <= 1000 );
while ( condition ) {
statement(s);
}
_____________________An example_____________________
while ( counter > 1000 ) {
num.Text = counter;
counter = counter + 1;
}
for ( init; condition; increment ) {
statement(s);
}
________________________An example________________________
for ( counter = 1; counter <= 1000; counter += 1 ) {
acc += counter;
}
for ( init; condition; increment ) {
for ( init; condition; increment ) {
statement(s);
}
statement(s);
}
The nested while loop format is
while ( condition ) {
while ( condition ) {
statement(s);
}
statement(s);
}
The nested do ... while loop format is
do {
statement(s);
do {
statement(s);
}
while( condition );
}
while( condition );
|
“Argued that winning a silver medal is the worst, as it means being the top loser.” ― Jerry Seinfeld |