COP1334 C++ Midterm (Ch. 3)

¡Supera tus tareas y exámenes ahora con Quizwiz!

39

What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3;

3 * 2

In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2;

cin object

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

true

The cin >> statement will stop reading input when it encounters a newline character.

Ten

The statement cin >> setw(10) >> str; will read up to this many characters into str

false

The statement cout << setprecision(5) << dollar << endl; will output $5.00 to the screen.

4.0

What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0;

2

What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2;

Parentheses

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

data type of the variable

When the final value of an expression is assigned to a variable, it will be converted to:

True

When C++ is working with an operator, it strives to convert the operands to the same type.

overflows

When a variable is assigned a number that is too large for its data type, it:

setw

This manipulator is used to establish a field width for the value immediately following it.

fixed

This stream manipulator forces cout to print the digits in fixed-point notation.

cstdlib

To use the rand() function, you must #include this header file in your program.

13

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;

+

When this operator is used with string operands it concatenates them, or joins them together.

7

Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 const int MY_VAL = 99; 7 MY_VAL = 77; 8 cout << MY_VAL << endl; 9 return 0; 10 }

left to right

Associativity is either right to left or

-3

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;

>>, <<

The ______ operator always follows the cin object, and the ______ operator follows the cout object.

number = number + 1;

Which statement is equivalent to the following? number += 1;

x *= 2;

Which statement is equivalent to the following? x = x * 2;

getline(cin, address);

Which statement will read an entire line of input into the following string object? string address;

(Parentheses)

You can use these to override the rules of operator precedence in a mathematical expression.


Conjuntos de estudio relacionados

Computer Programming Benchmark #2

View Set

Chapter 23: Nursing Care of the Newborn with Special Needs

View Set

Chapter 5 Examining Research Problems, Purposes, and Hypotheses

View Set

Fitness For Life - Section One - Chapter One

View Set

Neonatal Resuscitation Review questions

View Set