Question

1) Convert the "Switch" statement to "if/else"

Convert the following switch statement to an equivalent if/else: switch(x) case 10: cost- 1; break; case 20: cost- 2; break; default: cost 0; 0 if (cost =-1) x = 1; else if (cost-20) x = 2; else x = 0; O if ( x = 10) cost = 1; else if (x = 2) cost-20; else cost = 0; if (case10) cost 1; else if (case 20) cost- 2; else cost-0 if (cost1) case- 10; else if (cost 2) case 20; else cost 0; if (x10) cost 1; else if (x20) cost 2; else cost 0;

2) Convert from for loop to while loop

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

1) E (Last Option)

if(x==10) cost = 1 else if(x==20) .. . .. . .. .. . ..


2) B

int k = 0;
while (k < 10) {
cout<<k;
k++;

}



Thanks, PLEASE UPVOTE if helpful

Add a comment
Know the answer?
Add Answer to:
1) Convert the "Switch" statement to "if/else" 2) Convert from for loop to while loop Convert...
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