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);
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
You might also like to view...
Changes to the backup window take effect ______.
A. from the next billing cycle B. after 30 minutes C. immediately D. after 24 hours
Supply-chain automation
a. streamlines organizations by eliminating transactional middlemen. b. is one way Dell Computer keeps its costs low. c. links computers at different companies. d. All of the above e. None of the above