Convert the following mathematics expressions to C++ expressions. Use the declarations provided. Indicate the appropriate header file for any library function used. Be sure you initialize any variables whose values you are using to reasonable values for the library functions you are using.

Values used for initialization are arbitrary except for obvious things, such as the sign of the argument for the sqrt must be nonnegative and the sign of the first argument (the base for the exponential) for the pow function cannot be negative unless the second argument is an integer.
a) ```
//no include file necessary for this expression
int y, x = 39; // any value for x
y = x ??x ??x;
//alternate solution using pow function.
#include
using namespace std;
y = pow(x, 3);
```
b) ```
#include
using namespace std;

int y; int x = -23; // any value for x
y = abs(x);
// or
#include
double y, x = -79.8; // any value for y
y = fabs(x);
```
c) ```
#include
using namespace std;
double z, x = 2.6;
z = pow(x, 1.6);
```
d) ```
#include
using namespace std;
double z, area = 144; // here area must not be
// negative
z = area ??sqrt(area);
// the pow function can be used for this:
z = pow (area, 1.5);
```
e) ```
// no includes are necessary here
double p, x = 3, y = -4;
//any values for x, y except x = y
p = (x * x + y) / (x * x - y);
//specifications can be interpreted to allow
//int variables as well
```

Computer Science & Information Technology

You might also like to view...

A(n) ________ is a field that obtains its data by performing a calculation or computation, using a formula

A) expression B) calculated field C) multivalued field D) crosstab field

Computer Science & Information Technology

Which of the following document properties does Word NOT collect automatically?

A. time spent editing a document B. Enhanced ScreenTips C. themes used in a document D. the number of times a document has been revised

Computer Science & Information Technology