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 42 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
YES! Correct, THANKS for helping me on my review


nanny

  • Member
  • Posts: 313
Reply 3 on: Yesterday
Thanks for the timely response, appreciate it

 

Did you know?

Normal urine is sterile. It contains fluids, salts, and waste products. It is free of bacteria, viruses, and fungi.

Did you know?

Between 1999 and 2012, American adults with high total cholesterol decreased from 18.3% to 12.9%

Did you know?

Ether was used widely for surgeries but became less popular because of its flammability and its tendency to cause vomiting. In England, it was quickly replaced by chloroform, but this agent caused many deaths and lost popularity.

Did you know?

The first documented use of surgical anesthesia in the United States was in Connecticut in 1844.

Did you know?

The effects of organophosphate poisoning are referred to by using the abbreviations “SLUD” or “SLUDGE,” It stands for: salivation, lacrimation, urination, defecation, GI upset, and emesis.

For a complete list of videos, visit our video library