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?


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

Transaction processing enables a program to ________ or ________ a transaction based on whether the transaction was successful.

a. save, delete b. commit, rollback c. save, rollback d. commit, delete

Computer Science & Information Technology

A firewall typically sits between a network and its individual computers.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Picture formatting options that control the manner in which text wraps around a picture or other object.

What will be an ideal response?

Computer Science & Information Technology

Medium to large businesses, or those with large data-storage needs, are more likely to use Microsoft SQL Server or Oracle as their DBMS.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology