Filters
Question type

Study Flashcards

The following statement sets sum1, sum2, and sum3 all to zero. sum1 = sum2 = sum3 = 0;

A) True
B) False

Correct Answer

verifed

verified

The following two statements will assign the same value to result. result = a + b * c; result = b * c + a;

A) True
B) False

Correct Answer

verifed

verified

When an arithmetic expression contains two or more different operators, such as * and +, the order in which the operations is done is determined by


A) left to right order.
B) operator precedence.
C) operator associativity.
D) the programmer.
E) the compiler.

F) B) and D)
G) A) and B)

Correct Answer

verifed

verified

Which of the following statements about named constants is/are True?


A) A named constant must be initialized with a value at the time it is declared.
B) The identifier name of a named constant can only contain capital letters and underscores.
C) The initial value of a named constant, cannot be changed during the program execution.
D) All 3 of the above statements are True.
E) Statements A and C are True, but B is not.

F) A) and D)
G) B) and C)

Correct Answer

verifed

verified

The following 4 lines of C++ code, use strings. string firstName; // Define a string object Char lastName[7]; // Define a C-string FirstName = "Abraham"; // Assign a value to the string object LastName = "Lincoln"; // Assign a value to the C-string Which of the following statements is /are True?


A) The string object is defined incorrectly because no size is given for it.
B) The 2 string definitions are correct, but the 2 assignment statements are wrong.
C) The string object is assigned a value correctly, but the C-string is not.
D) The C-string is assigned a value correctly, but the string object is not.
E) All 4 lines of code are correct.

F) A) and D)
G) B) and C)

Correct Answer

verifed

verified

Operator associativity is either left to right or


A) top to bottom.
B) front to back.
C) right to left.
D) inside to outside.
E) nothing else; it is always left to right.

F) D) and E)
G) A) and C)

Correct Answer

verifed

verified

________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.


A) An input device
B) The cin object
C) The cout object
D) A preprocessor
E) Nothing

F) None of the above
G) A) and D)

Correct Answer

verifed

verified

________ can be used to override the rules of operator precedence.


A) Some operators
B) Parentheses
C) Operands
D) Associativity
E) Nothing

F) All of the above
G) A) and E)

Correct Answer

verifed

verified

The following statement number = rand() % 5 + 10; Assigns number a value in the range of


A) 5 - 10
B) 0 - 15
C) 5 - 15
D) 10 - 15
E) none of the above.

F) B) and C)
G) B) and E)

Correct Answer

verifed

verified

Which of the following statements doubles the value stored in answer?


A) answer += 2;
B) answer *= 2;
C) answer = answer * 2;
D) All three of the above
E) Both B and C, but not A

F) B) and D)
G) All of the above

Correct Answer

verifed

verified

In any program that uses the cin object, you must #include


A) the iostream header file.
B) the fstream header file.
C) >> and << operators.
D) named constants.
E) none of the above.

F) All of the above
G) D) and E)

Correct Answer

verifed

verified

The following two expressions evaluate to the same thing: c + a * b c + (a * b)

A) True
B) False

Correct Answer

verifed

verified

The following pair of C++ statements will cause 3.5 to be output. double number = 7 / 2; cout << number;

A) True
B) False

Correct Answer

verifed

verified

The only difference between C-strings and string objects is how they are declared and internally stored. They are used exactly the same way.

A) True
B) False

Correct Answer

verifed

verified

When converting some algebraic expressions to C++, you may need to insert ________ and ________ that do not appear in the algebraic expression.


A) values, exponents
B) operators, calculations
C) operators, operands
D) operators, parentheses
E) operands, parentheses

F) A) and B)
G) A) and C)

Correct Answer

verifed

verified

The statement cout << setw(4) << num4 << " ";


A) outputs the value of num4 rounded to 4 decimal places.
B) outputs "setw(4) " before the value in the variable num4.
C) outputs the first 4 digits of the number stored in num4.
D) outputs the value stored in num4 four times.
E) does none of above.

F) All of the above
G) None of the above

Correct Answer

verifed

verified

When an operator has two operands of different data types, C++ always converts them both to double before performing the operation.

A) True
B) False

Correct Answer

verifed

verified

The ________ stream manipulator can be used to establish a field width for the value immediately following it.


A) cin
B) setField
C) setw
D) iomanip
E) width

F) A) and E)
G) B) and D)

Correct Answer

verifed

verified

The ________ object causes data to be input from the keyboard.


A) cin
B) cout
C) keyboard buffer
D) standard input
E) dataIn

F) A) and B)
G) A) and C)

Correct Answer

verifed

verified

Which of the following expressions will evaluate to 2.5?


A) static_cast<double>(5/2)
B) static_cast<double>(5) /2
C) 5/static_cast<double>(2)
D) All three of the above
E) Both B and C, but not A

F) C) and D)
G) A) and D)

Correct Answer

verifed

verified

Showing 21 - 40 of 40

Related Exams

Show Answer