|
Because in most computer algorithms that have been developed, the algorithm
|
Explanation:
|
Note:
|
A typical do-statement will look like this:
|
|
|
|
a = 1;
do
{
System.out.println(a);
a++;
}
while ( a <= 4 )
System.out.println("Done");
|
Output:
1
2
3
4
Done
|
Flow chart of this program:
|
|
|
How to "read" the diagram:
|
a = 1;
do
{
System.out.println(a);
a++;
}
while ( a <= 4 )
System.out.println("Done");
|
Structure diagram of this program:
|
|
| While-statement | Do-statement |
|---|---|
a = 10;
while ( a <= 4 )
{
System.out.println(a);
a++;
}
System.out.println(a); // prints 10
|
a = 10;
do
{
System.out.println(a);
a++;
}
while ( a <= 4 ) ;
System.out.println(a); // Prints 11
|
|
|
|
Explanation:
|
|