Question

Convert the while loop in the program below into a for loop. int Taylor = 10,...

Convert the while loop in the program below into a for loop.

int Taylor = 10, Justin = 6, Selena=3;

cout << “Que Pasa? ” << “\n\n”;

while (Selena > 0)

{

cout << Taylor << “@ “ << Justin << “\n” ;

--Selena;

Taylor++;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Output:
--------
Que Pasa?

10@ 6
11@ 6
12@ 6

Explanation:
--------------
Before while loop "Que Pasa?\n\n" is printed. \n is a newline character
while loop trace here
Iteration 1
   Taylor = 10 and Justin = 6
   so, "10@ 6" is printed
   --Selena changes Selena to 2
   Taylor++ changes Taylor to 11
Iteration 2
   Taylor = 11 and Justin = 6
   so, "11@ 6" is printed
   --Selena changes Selena to 1
   Taylor++ changes Taylor to 12
Iteration 3
   Taylor = 12 and Justin = 6
   so, "12@ 6" is printed
   --Selena changes Selena to 0
   Taylor++ changes Taylor to 13
Add a comment
Know the answer?
Add Answer to:
Convert the while loop in the program below into a for loop. int Taylor = 10,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT