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


sailorcrescent

  • Member
  • Posts: 334
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

The immune system needs 9.5 hours of sleep in total darkness to recharge completely.

Did you know?

About 100 new prescription or over-the-counter drugs come into the U.S. market every year.

Did you know?

More than 34,000 trademarked medication names and more than 10,000 generic medication names are in use in the United States.

Did you know?

Urine turns bright yellow if larger than normal amounts of certain substances are consumed; one of these substances is asparagus.

Did you know?

Patients who have been on total parenteral nutrition for more than a few days may need to have foods gradually reintroduced to give the digestive tract time to start working again.

For a complete list of videos, visit our video library