Question

What will the output be in the following? int a, b, c; a-b-0; c 5; ific< 1011 (a = = 0 &&b != 0)) 3. cout<<True; else cout<<False, What will the output be in the following? a. int icount; 4. do count = 0; cout<<The count is <cicount<<endl; while(icount<10); int count = 0; do b. cout<<The count is “<<count<<endl; while++icount<10); c. for(int n 5; n>0; n-) cout<<n;
0 0
Add a comment Improve this question Transcribed image text
Answer #1

3)

The output will be "True". This is because in the program,The variables are initialised as follows:

a=0

b=0

c=5

Now, in the if condition, c<10 evaluates to true. remember, if any field in the or (||) expression evaluates to true, then if block will run irrespective of the other expression in the or statement.

So we, get the output as "True" since our if block will execute and not the else block.

4)

a)The output will be "The count is 0" infinite times. This is because in the do-while loop, we are not incrementing the value of icount. icount always remains 0, so our do-while loop will never terminate, as icount will always remain smaller than 10.

b)The output is:

The count is 0

The count is 1

The count is 2

The count is 3

The count is 4

The count is 5

The count is 6

The count is 7

The count is 8

The count is 9

This is because, as icount equals 10, the loop will terminate.

c)The output is: 54321
This is because, we are printing n 5 times, and n is decrementing each time by 1 (initialised with 5).

If you liked the solution, don't forget to give a THUMBS UP!. In case of any doubt, please let me know in the comments section. I'll get it resolved :) :)

Add a comment
Know the answer?
Add Answer to:
What will the output be in the following? int a, b, c; a-b-0; c 5; ific<...
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