Question

e following C++ program and provide the correct output: int x = 20, count=0; do { cout << x; x = 4* (x + 5)/5; count++; }whil trace
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

output: 2020

it prints 20 value 2 times.it is not 2020

tracing:

x is an integer and having value 20

x=20

count=0 and it is also a integer

There a do-while loop.

Now loop is initiated.

And loop iterates for two times because while (count<2).

1st iteration

cout<<x

It prints 20.

x=4*(x+5)/5

x=4*(20+5)/5

x=4*25/5

x=100/5=20

So again x=20

In next line count incremented so count =1

count<2 --> 1<2,true

2nd iteration

cout<<x

It prints 20 again.

Again x=4*(x+5)/5

x=20

count incremented so count=2

count<2 ,2<2 false so

The final output is 2020.

Add a comment
Know the answer?
Add Answer to:
trace e following C++ program and provide the correct output: int x = 20, count=0; do...
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