The document contains 7 multiple choice questions about C++ concepts like functions, operators, input/output, and bugs. The questions cover topics like header files needed for certain functions, stream manipulators, order of operations, reading input, and examples of program bugs. Correct answers are provided for each question.
1. The function, pow(x, 5.0), requires this header file.
A. cstdlib
B. cmath
C. iostream
D. iomanip
ANSWER: A
This manipulator is used to establish a field width for the value immediately
following it.
A. field_width
B. set_field
C. setw
D. iomanip
ANSWER: A
Assume that x is an int variable. What value is assigned to x after the
following assignment statement is executed x = -3 + 4 % 6 / 5;
A. 0
B. 1
C. 2
D. 3
ANSWER: D
This stream manipulator forces cout to print the digits in fixed-point notation.
A. setprecision(2)
B. setw(2)
C. fixed
D. setfixed(2)
ANSWER: B
Determine the value of the following expression 7 / 3 * (8 % 3 + 3.5)
A. 11
B. 11.0
C. 5.0
D. 8
ANSWER: C
Which of the following lines correctly reads a value from the keyboard and
stores it in the variable named myFloat?
A. cin >> myFloat;
B. cin << myFloat;
C. cin >> "myFloat";
D. cin >> myFloat >> endl;
ANSWER: B
Which of the following is not an example of a program bug?
A. Run-time error
B. Operator error
C. Syntax error
D. Logic error
ANSWER: C