This topic contains a solution. Click here to go to the answer

Author Question: Analyze the following program fragment:int x;double d = 1.5;switch (d) { case 1.0: x = 1; case 1.5: ... (Read 68 times)

kodithompson

  • Hero Member
  • *****
  • Posts: 566

Question 1

What is y after the following switch statement is executed?

int x = 3; int y = 4;
switch (x + 3) {
case 6: y = 0;
case 7: y = 1;
default: y += 1;
}

◦ 1
◦ 2
◦ 3
◦ 4
◦ 0

Question 2

Analyze the following program fragment:

int x;
double d = 1.5;

switch (d) {
case 1.0: x = 1;
case 1.5: x = 2;
case 2.0: x = 3;
}

◦ The program has a compile error because the required break statement is missing in the switch statement.
◦ The program has a compile error because the required default case is missing in the switch statement.
◦ The switch control variable cannot be double.
◦ No errors.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by kodithompson on May 6, 2020

tdewitt

  • Sr. Member
  • ****
  • Posts: 318
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 25% of students answer this correctly




kodithompson

  • Member
  • Posts: 566
Reply 2 on: May 6, 2020
Great answer, keep it coming :)


miss.ashley

  • Member
  • Posts: 371
Reply 3 on: Yesterday
Gracias!

 

Did you know?

The oldest recorded age was 122. Madame Jeanne Calment was born in France in 1875 and died in 1997. She was a vegetarian and loved olive oil, port wine, and chocolate.

Did you know?

Nearly all drugs pass into human breast milk. How often a drug is taken influences the amount of drug that will pass into the milk. Medications taken 30 to 60 minutes before breastfeeding are likely to be at peak blood levels when the baby is nursing.

Did you know?

Adults are resistant to the bacterium that causes Botulism. These bacteria thrive in honey – therefore, honey should never be given to infants since their immune systems are not yet resistant.

Did you know?

Cancer has been around as long as humankind, but only in the second half of the twentieth century did the number of cancer cases explode.

Did you know?

Persons who overdose with cardiac glycosides have a better chance of overall survival if they can survive the first 24 hours after the overdose.

For a complete list of videos, visit our video library