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 33 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
Excellent


lkanara2

  • Member
  • Posts: 329
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

Since 1988, the CDC has reported a 99% reduction in bacterial meningitis caused by Haemophilus influenzae, due to the introduction of the vaccine against it.

Did you know?

Acetaminophen (Tylenol) in overdose can seriously damage the liver. It should never be taken by people who use alcohol heavily; it can result in severe liver damage and even a condition requiring a liver transplant.

Did you know?

The longest a person has survived after a heart transplant is 24 years.

Did you know?

Alcohol acts as a diuretic. Eight ounces of water is needed to metabolize just 1 ounce of alcohol.

Did you know?

People with high total cholesterol have about two times the risk for heart disease as people with ideal levels.

For a complete list of videos, visit our video library