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...

The access method used when a workstation sends out a jam signal before transmitting data is

A) Collision detection B) Token passing C) Collision avoidance D) DQDB

Computer Science & Information Technology

When you want to enhance or customize a video you have created, use _______ .

A. video-editing software B. animation software C. software development kits D. transitions

Computer Science & Information Technology