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...
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...
maybe...
Code:int i = 0, j = 0; while ( j < 4 ) { do while ( i < 3 ) { cout << "The coordinate is " << i << ", " << j << i++ } j++ }
>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:
With do..while loopsCode:int i, j = 0; while ( j < 4 ) { i = 0; while ( i < 3 ) { cout<<"The coordinate is "<< i <<", "<< j <<endl; i++; } j++; }
-PreludeCode:int i, j = 0; do { i = 0; do { cout<<"The coordinate is "<< i <<", "<< j <<endl; i++; } while ( i < 3 ); j++; } while ( j < 4 );
My best code is written with the delete key.