Analyze the following fragment:
double sum = 0;
double d = 0;
while (d != 10.0) {
d += 0.1;
sum += sum + d;
}
a. The program does not compile because sum and d are declared double, but assigned with integer value 0.
b. The program never stops because d is always 0.1 inside the loop.
c. The program may not stop because of the phenomenon referred to as numerical inaccuracy for operating with floating-point numbers.
d. After the loop, sum is 0 + 0.1 + 0.2 + 0.3 + ... + 1.9
c The correct answer is C. There is no guarantee that d will be exactly 10.0 because real numbers are represented using approximation in a computer system.
You might also like to view...
A clothing store chain tracks the sale of each product at each location. Managers use this information to calculate the organization's profits, to track inventory needs, and to determine which styles and fabrics are the most popular among its customers. This is an example of quality information that is ___________.
A. flexible B. economical C. relevant D. verifiable
If a major error is made when typing data into a cell, click the Cancel box in the formula bar or press the ESC key to erase the entire entry, and then reenter the data from the beginning.
Answer the following statement true (T) or false (F)