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

Author Question: Analyze the following fragment:double sum = 0;double d = 0;while (d != 10.0) { d += 0.1; sum += sum + d;} (Read 44 times)

jon_i

  • Hero Member
  • *****
  • Posts: 549

Question 1

Is the following loop correct?

for (; ; );

◦ Yes
◦ No

Question 2

Analyze the following fragment:

double sum = 0;
double d = 0;
while (d != 10.0) {
d += 0.1;
sum += sum + d;
}

◦ After the loop, sum is 0 + 0.1 + 0.2 + 0.3 + ... + 1.9.
◦ The program may not stop because of the phenomenon referred to as numerical inaccuracy for operating with floating-point numbers.
◦ The program does not compile because sum and d are declared double, but assigned with integer value 0.
◦ The program never stops because d is always 0.1 inside the loop.


Related Topics

Need homework help now?

Ask unlimited questions for free

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

medine

  • Sr. Member
  • ****
  • Posts: 344
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




jon_i

  • Member
  • Posts: 549
Reply 2 on: May 6, 2020
:D TYSM


coreycathey

  • Member
  • Posts: 333
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

More than 150,000 Americans killed by cardiovascular disease are younger than the age of 65 years.

Did you know?

Only one in 10 cancer deaths is caused by the primary tumor. The vast majority of cancer mortality is caused by cells breaking away from the main tumor and metastasizing to other parts of the body, such as the brain, bones, or liver.

Did you know?

The training of an anesthesiologist typically requires four years of college, 4 years of medical school, 1 year of internship, and 3 years of residency.

Did you know?

According to the National Institute of Environmental Health Sciences, lung disease is the third leading killer in the United States, responsible for one in seven deaths. It is the leading cause of death among infants under the age of one year.

Did you know?

The first war in which wide-scale use of anesthetics occurred was the Civil War, and 80% of all wounds were in the extremities.

For a complete list of videos, visit our video library