code fragment pls help

• 04-14-2002
Damo
code fragment pls help
Trying to rewrite the following code fragment using while() and do-while() statements.

> int i, j;
> for (j=0; j < 4; j++)
> for (i=0; i < 3; i++)
> cout << "The coordinate is " << i << ", " << j <<
>endl;

A hand would be very much appreciated...
• 04-14-2002
Nutshell
maybe...
Code:

```int i = 0, j = 0; while ( j < 4 ) {   do while ( i < 3 ) {       cout << "The coordinate is " << i << ", " << j <<       i++   }   j++ }```
• 04-15-2002
Prelude
>Trying to rewrite the following code fragment using while() and do-while() statements.
That snippet is better suited to for loops since you know exactly how many times each loop is to run, but since you asked the equivalent while and do..while snippets would be:

With while loops:
Code:

```int i, j = 0; while ( j < 4 ) {   i = 0;   while ( i < 3 ) {     cout<<"The coordinate is "<< i <<", "<< j <<endl;     i++;  }  j++; }```
With do..while loops
Code:

```int i, j = 0; do {   i = 0;   do {     cout<<"The coordinate is "<< i <<", "<< j <<endl;     i++;   } while ( i < 3 );   j++; } while ( j < 4 );```
-Prelude