Each of the following lines of code purport to round the results of the division of doubles to the nearest integer value (but still of type double). All are correct C++ code but some do not round correctly. Tell which rounds down, up, or to the nearest integer value, or is not reasonable Assume that math.h has been included, and that all variables have appropriate values.

double x, y, z;
a) ```
z = ceil(x/y);a)
```
b) ```
z = ceil(x/y-0.5);
```
c) ```
z = floor(x/y-0.5);
```
d) ```
z = floor(x/y+0.5);
```
e)```
z = floor(x/y);
```


a) rounds up -- to the next integer greater than or equal to x/y
b) OK rounds to the integer nearest to x/y, exact 1/2 values round down
c) not reasonable. x/y with value 1.25 gives 0 result.
d) OK rounds to the integer nearest to x/y, exact 1/2 values round up
e) rounds down to the next integer less than or equal to x/y

Computer Science & Information Technology

You might also like to view...

One disadvantage to e-ink technology used with some e-readers is that it ________

A) requires an external light for night reading B) causes eye strain C) cannot be read in bright light D) has a short battery life

Computer Science & Information Technology

Unlike Unix, Windows, and Mac OS X, Linux is ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

When you must restore user service by rerouting, what is the second type of circuit you preempt?

a. Spare channels. b. Active on-call circuits. c. Nonactive on-call circuits. d. Circuits with 00 RP codes.

Computer Science & Information Technology

In a standard list element, the list items are ____-level elements.

A. inline B. inline-block C. block D. table

Computer Science & Information Technology