Engineering Problem Solving with C++, 3e Chapter 2 Test Bank
5. What is the output of the following program
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{ int WholeNumber;
double Real1, Real2;
WholeNumber = 76;
Real1 = 3.167;
Real2 = -24.103;
cout << setw(6) << WholeNumber << endl;
cout << setiosflags(ios::fixed);
cout << setprecision(2) << Real1 << “, ” << Real2 << endl;
cout << setiosflags(ios::showpoint) << Real2 << 8.376 << endl;
return 0;
}
6. Which of the following are valid on the left side of an assignment operator?
A. A numeric constant
B. An expression such as 8*6
C. A declared constant
D. A variable
E. All of the above are valid on the left side of an assignment operator.
7. Which of the following is valid on the right side of an assignment operator?
A. A numeric constant
B. An expression such as 8*6
C. A declared constant
D. A variable
E. All of the above are valid on the right side of an assignment operator.
8. The operator >> is used to
A. Take a value from the input stream an store it into a variable
B. Take a value from a variable and place it into the output stream
C. Perform integer division and produce the remainder of the division
D. Specify that the left hand operand is much larger than the right hand operand.
9. The file which must appear in a #include preprocessor statement if you are using the fabs
function is …
A. iostream
B. iomanip
C. cmath
D. string