Hogan chapter 3

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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

39

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

4.0

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; 7 MY_VAL = 77; 8 cout << MY_VAL << endl; 9 return 0; 10 } 6 8 9 7

6

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 = 77; 7 MY_VAL = 99; 8 cout << MY_VAL << endl; 9 return 0; 10 } 6 8 9 7

7

The ______ operator always follows the cin object and the ______ operator always follows the cout object. binary, unary conditional, binary <<, >> >>, << None of the above

>>, <<

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 store in the variable num4. E. None of these.

A

Arithmetic operators that share the same precedence have right to left associativity. True False

False

If you want to know the length of the string that is stored in a string object, you can call the objects size member function. True False

False

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

True

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. True False

True

You can use these to override the rules of operator precedence in a mathematical expression. [Brackets] (Parentheses) {Braces} The escape character \ None of these

(Parentheses)

When this operator is used with string operands it concatenates them or joins the together. & * % + None of the above

+

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; 0 1 2 -3 None of these

-3

What value is stored in x given the following statements; int x; x = 3 / static_cast<int>(4.5 + 6.4); 3 0 .275229 3.3 None of these

0

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; 13 18 0 unknown

13

What value will be printed on the screen when the following statement executes? cout << 6 - 3 * 2 + 7 - 10 / 2 << endl; 8 6 1.5 2

2

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

3 * 2

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

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. True False

True

When a variable is assigned a number that is too large for its data type, it: underflows overflows reverses polarity exceeds expectations None of the above

overflows

This manipulator is used to establish the field width for the value immediately following it. field_width set_field setw inmanip None of the above

setw

When converting some algebraic expressions to C++, you may need to insert ______ that do not appear in the algebraic expression. Parentheses Exponents Calculations Coercions

Parentheses

The statement cin >> setw(10) >> str; will read up to this many characters into str. Nine Ten Eleven Eight None of these.

Ten

When the final value of an expression is assigned to a variable, it will be converted to: The smallest C++ data type The largest C++ data type The data type of the variable The data type of the expression None of the above

The data type of the variable

You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written? cin << length, width, height; cin.get(length, width, height); cin >> length >> width >> height; cin >> length, width, height; cin << length; width; height;

cin >> length >> width >> height;

The _________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed. Output stream cin object cout object Preprocessor None of the above

cin object

This statement will pause the screen until the [Enter] key is pressed. cin; cin.getline(); cin.get(); cin.ignore(); cin.input();

cin.get();

This function tells the cin object to skip one or more characters in the keyboard buffer. cin.ignore cin.jump cin.hop cin.skip None of the above

cin.ignore

This function, pow(x, 5.0), requires this header file. cstdlib cmath cstring iostream iomanip

cmath

When using the sqrt function you must include this header file. cstdlib cmath cstring iomanip iostream

cmath

To use the rand() function, you must #include this header file in your program. iostream iomanip iorand cstdlib None of these

cstdlib

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

number = number + 1;

This stream manipulator forces cout to print the digits in fixed-point notation. setprecision(2) setw(2) fixed setfixed(2) None of these

fixed

_____ reads a line of input, including leading and embedded spaces and stores it in a string object. cin.get getline cin.getline get None of these

getline

Which statement will read an entire line of input into the following string object? string address; cin << address; cin address; getline(cin, address); cin.get(address) None of the above

getline(cin, address);

In any program that uses the cin object, you must include the __________. compiler iostream header file linker << and >> operators None of the above

iostream header file

This manipulator causes the field to be left-justified with padding spaces printed to the right. left_justify right left left_pad None of the above

left

Associativity is either right to left or Top to bottom Front to back left to right Undeterminable None of the above

left to right

The total number of digits that appear before and after the decimal point is sometimes referred to as _______. May have more than one answer. floating points significant digits precision none of these

significant digits, precision

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

x *= 2;


Kaugnay na mga set ng pag-aaral

Chapter 4 Database Design Using Normalization

View Set

What are the primary responsibilities of the Federal Reserve Board?

View Set

WGU Psych - C476: Psychosis Meds

View Set

Altered Glucose Metabolism During Pregnancy

View Set

CSC Chapter 2 - The Capital Market

View Set