Write code that declares x, y, and z as double variables. Then write code that causes z to be assigned the result of x divided by y, rounded as indicated below. Be sure to #include the header file that declares the library functions you use.

a) round up
b) round down
c) round to the nearest integer. Does your code round an exact half up or down? say 2.5?

The header is required for each answer.
```
#include
using namespace std;
double x, y, z;
We mentioned what the code does for 2.5. Suppose x is 5.0 and y is 2.0 so we get a quotient of 2.5
```
a) ```
//round up
z = ceil(x/y);
for above values we get 3.0
```
b) ```
// round down
z = floor(x/y);
for above values we get 2.0
```
c) ```
//round nearest integer
z = floor (x/y + 0.5);
For above values of x and y we get 3
```

Computer Science & Information Technology

You might also like to view...

Windows Task Manager can be launched using any of the following methods EXCEPT ________

A) pressing Shift + Esc B) right-clicking the taskbar and selecting Task Manager C) right-clicking the Start button and selecting Task Manager D) pressing Ctrl + Alt + Delete

Computer Science & Information Technology

What is the problem with using bandwidth without permission?

What will be an ideal response?

Computer Science & Information Technology