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
```
You might also like to view...
A one-to-many form allows you to work with data from two tables on a single screen
Indicate whether the statement is true or false
If bullets have been applied to several paragraphs and the bullets button is clicked again, what happens?
A) The bullet formatting is removed. B) You will cycle through a limited number of bullet options. C) A dialog box pops up in which you can select a different type of bullet. D) The bullets are made larger.
If configuring a layer 3 EtherChannel using two physical interfaces, how many different times must the no switchport command be configured?
A) 1 B) 2 C) 3 D) Never
The ____ Window button opens a separate window that displays values and formulas for specific cells that you choose to monitor.
A. Formula B. Watch C. Error D. Monitoring