C++ Chapter 3 Test

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

FALSE

The fixed manipulator causes a number to be displayed in scientific notation. (T/F)

cmath

The function, pow(x, 5.0) requires this header file.

9

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

FALSE

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. (T/F)

+

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

cmath

When using the sqrt function you must include this header file.

It allows 4 spaces for the value in the variable num4.

Which is true about the following statement? cout << setw(4) << num4 << " " ;

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

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

getline(cin, address);

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

number = number + 1;

Write a statement is equivalent to the following. number + = 1;

x * = 2;

Write a statement is equivalent to the following: x = x * 2;

cin.get()

Write a statement that will pause the screen, until the [Enter] key is pressed.

iostream header file

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

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 ;

>> , <<

The ________ operator always follows the cin object, and the _________ operator follows the cout object.

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. (T/F)

precision or significant figures

The total number of digits that appear before and after the decimal point is sometimes referred to as:

setw

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

cstdlib

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

cin.ignore

What function tells the cin object to skip one or more characters in the keyboard buffer?

4.0

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

39

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

0

What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4);

left

What manipulator causes the filed to be left-justified with padding spaces printed to the right?

fixed

What stream manipulator forces cout to print the digits in fixed-point notation?

2

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

x = 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;

TRUE

When C++ is working with an operator, it strives to convert the operands to the same type. (T/F)

FALSE

When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive. (T/F)

overflows

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

the data type of the variable

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

(parentheses)

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

getline

__________ reads a line of input, including leading and embedded spaces, and stores it in a string object.

-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


Kaugnay na mga set ng pag-aaral

RAW- LESSON 2 Patterns of Development

View Set

Business Dynamics - Chapter 5: Business Communications

View Set

Platyhelminthes, Nematoda, & Annelida

View Set

302 - Radiography - MCQ Revision

View Set

Strategic Management Chapter 1-5 Quizzes

View Set

Psych 2501: Quiz Answers for Exam 1

View Set