Page 84 - iprime_V2.2_class8
P. 84
The syntax of the 'do-while' loop is as follows:
Start
do
{
Body of do...while loop
[statements]
increment/decrement expression
} True conditional
expression
while(<conditional expression>);
For example:
False
public class DoWhileLoop
End
{
Flowchart of 'do-while' Loop
public static void main(String args[])
{
int i = 1;
do
{
System.out.println("The value
of i is: " + i);
i++;
}
while (i <= 10);
}
} Output
If we change the condition used in the preceding program from (i <= 10) to (i >= 10), the 'do-
while' loop executes the statements only once and stops executing. However, the condition is
false. The output will be displayed as shown.
Output
82 iPRIME (Ver. 2.2)–VIII

