Given the following code: double sum = 0.0; double i = 0.0; while(i != 10.0) { sum += i; i += (1.0/3); } a. What is wron
Posted: Tue Jul 12, 2022 8:19 am
Given the following code:
double sum = 0.0;
double i = 0.0;
while(i != 10.0) {
sum += i;
i += (1.0/3);
}
a. What is wrong with this code? (5 points)
Blank 1
b. Why is this a problem? (5 points)
Blank 2
c. Rewrite the code to fix the problem and return the expectedvalue of ‘sum’. (5 points)
Blank 3
double sum = 0.0;
double i = 0.0;
while(i != 10.0) {
sum += i;
i += (1.0/3);
}
a. What is wrong with this code? (5 points)
Blank 1
b. Why is this a problem? (5 points)
Blank 2
c. Rewrite the code to fix the problem and return the expectedvalue of ‘sum’. (5 points)
Blank 3