Question

What is the output of the following program segment? int count = 5; while(--count > 0)...

What is the output of the following program segment?

int count = 5;

while(--count > 0)

cout << count << " ";

cout << endl;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The output of the above C++ code segment is as follows:

Output : 4 3 2 1 

While condition pre-decrements count value first then compares with 0.. which is (4 > 0) and till (1 >0) the condition remains true and prints count value.

Add a comment
Know the answer?
Add Answer to:
What is the output of the following program segment? int count = 5; while(--count > 0)...
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