Rewrite the following while loops as for loops:

a) int i = 1;
while(i<=10)
{
if (i<5 && i !=2)
cout << 'X';
i++;
}

b) int i =1;
while(i<=10)
{
cout << 'X';
i = i + 3;
}
c) int n = 100;
do
{
cout << 'X';
n = n + 100;
}while(n < 1000);

a) for( int i=1; i<=10; i++)
if (i<5 && i !=2)cout << 'X';
b) for(int i=1; i<=10; i = i + 3)
cout << 'X';
c) for( int n = 100; n <1000; n = n + 100)
cout << 'X';

Computer Science & Information Technology

You might also like to view...

Audio files of the type .aud can be embedded in PowerPoint

Indicate whether the statement is true or false

Computer Science & Information Technology

In the Intel architecture, instructions are fetched into the __________ cache.

a. L2 b. L1 code c. L1 data d. L2 code

Computer Science & Information Technology