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 87 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
Gracias!


vickyvicksss

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

 

Did you know?

Women are two-thirds more likely than men to develop irritable bowel syndrome. This may be attributable to hormonal changes related to their menstrual cycles.

Did you know?

Chronic marijuana use can damage the white blood cells and reduce the immune system's ability to respond to disease by as much as 40%. Without a strong immune system, the body is vulnerable to all kinds of degenerative and infectious diseases.

Did you know?

In ancient Rome, many of the richer people in the population had lead-induced gout. The reason for this is unclear. Lead poisoning has also been linked to madness.

Did you know?

Serum cholesterol testing in adults is recommended every 1 to 5 years. People with diabetes and a family history of high cholesterol should be tested even more frequently.

Did you know?

Illicit drug use costs the United States approximately $181 billion every year.

For a complete list of videos, visit our video library