Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6. Suppose that x and y are int variables, z is a double variable, and ch is a c

ID: 3563005 • Letter: 6

Question

6. Suppose that x and y are int variables, z is a double variable, and ch is a

char variable. Suppose the input statement is:

cin >> x >> y >> ch >> z;

What values, if any, are stored in x, y, z, and ch if the input is:

a. 35 62.78

b. 86 32A 92.6

c. 12 .45A 32

7. Which header file must be included to use the function steprecision?

8. Which header file must be included to use the function pow?

9. Which header file must be included to use the function sqrt?

10. What is the output of the following program?

#include <iostream>

#include <cmath>

#include <string>

using namespace std;

int main()

{

int x, y;

string message;

double z;

x = 4;

y = 3;

z = 2.5;

cout << static_cast<int>(pow(x, 2.0)) << endl;

cout << static_cast<int>(pow(z, y)) << endl;

cout << pow(x, z) << endl;

cout << sqrt(36.0) << endl;

z = pow(9.0, 2.5);

cout << z << endl;

message = "Using C++ predefined function";

cout << "Length of message = "

<< message.length() << endl;

return 0;

}

Explanation / Answer

6)
a) 35 62.78

x = 35
y = 62
ch = .
z = 78

b)
86 32A 92.6

x = 86
y = 32
ch = A
z = 92.6

c)
12 .45A 32


x = 12
y = 1974045909
ch = Special Symbol
z = 8.60052e-298


7)
<iomanip> header file

8)
<cmath> header file

9)
<cmath> header file

10)
Output:

16
15
32
6
243
Length of message = 29

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote