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 86 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
Thanks for the timely response, appreciate it


nguyenhoanhat

  • Member
  • Posts: 332
Reply 3 on: Yesterday
Excellent

 

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?

Asthma cases in Americans are about 75% higher today than they were in 1980.

Did you know?

Cytomegalovirus affects nearly the same amount of newborns every year as Down syndrome.

Did you know?

Aspirin may benefit 11 different cancers, including those of the colon, pancreas, lungs, prostate, breasts, and leukemia.

Did you know?

To maintain good kidney function, you should drink at least 3 quarts of water daily. Water dilutes urine and helps prevent concentrations of salts and minerals that can lead to kidney stone formation. Chronic dehydration is a major contributor to the development of kidney stones.

For a complete list of videos, visit our video library