Question: Loop Programming Practice Lab Part 1 70pts (10 points each): Take each of the loops programed here and give the equivalent loop asked for. Your
Loop Programming Practice Lab
Part 1 70pts (10 points each): Take each of the loops programed here and give the equivalent loop asked for. Your submission through eCampus for the entire lab should be a single .cpp file.
1. Convert the following for loop into a do/while loop
for (int i = 6; i < 10; i++)
cout << i << " ";
cout << endl;
2. Convert the while loop into a for loop
int w = 35;
while (--w>0)
{
if (w > 5)
w -= 4;
cout << "T-" << w << ", ";
}
cout << "Lift-off" << endl;
3. Convert this do/while loop into a for loop
int loop = 10;
do{
cout << --loop << " ";
} while (loop > 5);
cout << endl;
4. Convert this for loop into a do/while loop
int j = 17;
for (int i = 0;i { cout << i << " "; if (j-- % ++i == 0) i += j / 2; } cout << endl; 5. Convert this for loop into a while loop for (int i = 5, j = 8;;j++) { cout << i << ", "; i += j % 4; if (j < i) break; } 6. Convert this while loop into a for loop int x = 18; while (x) { if (x-- % 3) continue; cout << (x*x) << ", "; } 7. Convert this for loop into a do/while loop for (int y=39;;y++) { cout << y << ", "; y += y % 8; if (y > 90) break; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
