Computer Science Quiz 3
What will the value of x be after the following statements execute? int x = 0; int y = 5; int z = 4; x = y + z * 2; A) 13 B) 18 C) 0 D) unknown
A) 13
The only difference between the get function and the >> operator is that get reads the first character typed, even if it is a space, tab, or the [Enter] key. A) True B) False
A) True
When the fixed manipulator is used, the value specified by the setprecision manipulator will be the number of digits to appear after the decimal point. A) True B) False
A) True
This function tells the cin object to skip one or more characters in the keyboard buffer. A) cin.ignore B) cin.jump C) cin.hop D) cin.skip E) None of these
A) cin.ignore
The statement cin>>setw(10)>>str; will read up to this many characters into str. A) nine B) ten C) eleven D) eight E) None of these
A) nine
Which statement is equivalent to the following? number += 1; A) number = number + 1; B) number + 1; C) number = 1; D) None of these
A) number = number + 1;
When converting some algebraic expressions to C++, you may need to insert ________ that do not appear in the algebraic expression. A) parentheses B) exponents C) calculations D) coercions E) None of these
A) parentheses
In the following C++ statement, what will be executed first according to the order of precedence? result= 6-3*2+7-10/2; A) 6 - 3 B) 3 * 2 C) 2 + 7 D) 7 - 10 E) 10 / 2
B) 3 * 2
What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3; A) 3 B) 39 C) 15 D) 2
B) 39
If you want to know the length of the string that is stored in a string object, you can call the object's size member function. A) True B) False
B) False
In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision. A) True B) False
B) False
The statement cout<<setprecision(5)<<dollars<<endl; will output $5.00 to the screen. A) True B) False
B) False
When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive. A) True B) False
B) False
Which is true about the following statement? cout<<setw(4)<<num4<< " "; A) It allows four spaces for the value in the variable num4. B) It outputs "setw(4)" before the value in the variable num4. C) It should use setw(10) to output the value in the variable num10. D) It inputs up to four characters stored in the variable num4. E) None of these
B) It outputs "setw(4)" before the value in the variable num4.
The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed. A) output stream B) cin object C)cout object D) preprocessor E) None of these
B) cin object
The function, pow(x, 5.0), requires this header file. A) cstdlib B) cmath C) cstring D) iostream E) iomanip
B) cmath
When using the sqrt function you must include this header file. A) cstdlib B) cmath C) cstring D) iostream E) iomanip
B) cmath
In any program that uses the cin object, you must include the ________. A) compiler B) iostream header file C) linker D) >> and << operators E) None of these
B) iostream header file
This manipulator causes the field to be left-justified with padding spaces printed to the right. A) left_justify B) right C) left D) left_pad E) None of these
C) left
Which line in the following program will cause a compiler error? 1) #include <iostream> 2) using namespace std; 3) 4) int main() 5) { 6) constant MY_VAL = 77; 7) MY_VAL = 99; 8) cout<<MY_VAL<<endl; 9) return 0; 10 } A) 6 B) 8 C) 9 D) 7
D) 7