C++ MIDTERM

Ace your homework & exams now with Quizwiz!

Suppose that alpha and beta are int variables. The statement alpha = ++beta; is equivalent to the statement(s) ____.

beta = beta + 1; alpha = beta;

A ____ statement causes an immediate exit from the switch structure

break

The type____ is C++ 's method for allowing programmers to create their own simple data types.

enumeration

In C++, the symbol ==, which consists of two equal signs, is called the ____ operator.

equality

The statement cin.get(ch); inputs the next nonwhitespace character into the variable ch

false

When the statement cin >> num1 >> num2; executes, then after inputting a number into the variable num1 the program skips all trailing whitespace characters

false

An operator that has only one operand is called a unique operator

false; An operator that consists of only one operator is known as unary operators.

A comma is also called a statement terminator.

false; In C++, a semicolon is known as a statement terminator.

The memory allocated for a float value is ____ bytes.

four

If the possible range of values for a multiple selection statement cannot be reduced to a finite set of values, you must use the ____ structure.

if ... else

The function____ returns the next character in the input stream; it does not remove the character from the input stream.

peek

The maximum number of significant digits is called the

precision

____functions are those that have already been written and are provided as part of the system.

predefined

Which of the following is NOT a reserved word in C++?

select

____ is a parameterized stream manipulator.

setfill

In ____ evaluation, the computer evaluates a logical expression from left to right and stops as soon as the value of the expression is known.

short-circuit

A(n)____is a sequence of zero or more characters.

string

A(n) _____ is a collection of statements, and when it is activated, or executed, it accomplishes something.

subprogram

Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement sum += num executes, ____.

sum = 15

The smallest individual unit of a program written in any language is called a(n)

token

The escape sequence \r moves the insertion point to the beginning of the next line.

true

The maximum number of significant digits in float values is up to 6 or 7.

true

The operator ! is ____, so it only has one operand.

unary

In a C++ program,____ are used to separate special symbols, reserved words, and identifiers.

whitespaces

To use cin and cout in a program, the program must include the header file iostream.

True

When reading data into a char variable, after skipping any leading whitespace characters, the extraction operator >> finds and stores only the next character; reading stops after reading a single character.

True

Which of the following operators has the highest order of precedence? && < = !

!

You can disable assert statements by using the preprocessor directive ____.

#define NDEBUG

____ is a valid char value.

'A'

Suppose that ch1, ch2, and ch3 are variables of the type char. The input is: ​ A B C ​ What is the value of ch3 after the following statements execute? ​ cin.get(ch1); cin.get(ch2); cin.get(ch3);

'B'

Which of the following expressions evaluates to true?

(14 > = 5) & & ('A' < 'B')

Given the input stream variable cin, the expression ____ evaluates to true if the last input succeeded.

(cin)

When using a return statement, the return of any value other than ____ indicates that something went wrong during program execution.

0

The expression static_cast(6.9) + static_cast(7.9) evaluates to ____.

13

Suppose that x = 1565.683, y = 85.78, and z = 123.982. What is the output of the following statements? cout << fixed << showpoint;cout << setprecision(3) << x << ' '; cout << setprecision(4) << y << ' ' << setprecision(2) << z << endl;

1565.683 85.7800 123.98

The value of the expression 17 % 7 is ____.

3

The value of the expression 33/10, assuming both values are integral data types, is ____.

3

Suppose pay is a variable of type double. The statement cin >> pay; requires the input of a decimal number

False

When C++ evaluates a logical expression, any nonzero value is treated as _____.

TRUE

____ is a valid int value.

46259

Which of the following is the "less than or equal to" operator in C++?

>=

An example of a floating point data type is ____.

Double

Which of the following expressions evaluates to true?

Air" < "An

In C++, the ____ operator, written as ?: is a ternary operator

Conditional

If input failure occurs in a C++ program, the program terminates immediately and displays an error message.

False; If input failure occurs in a C++ program, the program does not terminate immediately displaying an error message, instead program quietly continues to execute with whatever values are stored in the variables and produces incorrect results.

In C++, reserved words are the same as predefined identifiers

False; Reserved words are typically referred as keywords. They cannot be redefined within in any programs.

The following statements will result in input failure if the input values are not on a separate line. (Assume that x and y are int variables.) cin >> x; cin >> y;

False; The input values can be in the same line separated by whitespaces or in separate lines.

In an output statement, each occurrence of endl advances the cursor to the end of the current line on an output device.

False; The manipulator endl is used to move the insertion point to the beginning of the next line.

An output stream is a sequence of characters from a computer to an output device.

True

The maximum number of significant digits in values of the double type is 15.

True

The number of input data extracted by cin and >> depends on the number of variables appearing in the cin statement

True; The number of input data extracted by cin and >> is based on the number of variables in the statement. If more number of inputs are given, then it just skips the additional input and take only required number of inputs.

Suppose a = 5. After the execution of the statement ++a; the value of a is 6

True; The pre-increment operator increments the value of a by 1.

Which of the following is the newline character?

\n

Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the statement alpha *= beta; executes, ____.

alpha = 50

Suppose that alpha and beta are int variables. The statement alpha = beta--; is equivalent to the statement(s) ____.

alpha = beta; beta = beta - 1;

The specification of the assert function is found in the header file ____.

cassert

Suppose that x and y are int variables. Which of the following is a valid input statement?

cin >> x >> y;

C++ has a special name for the data types istream and ostream. They are called

classes

To permit more than one statement to execute if an expression evaluates to true, C++ provides a structure called a ____ statement.

compound

You can use either a(n) ___ variable or a bool variable to store the value of a logical expression.

int

The value of the expression in a switch statement must be a(n) ____.

integral

_____ operators enable you to combine logical expressions.

logical

In C++, you can use a(n)_____ to instruct a program to mark those memory locations in which data is fixed throughout program execution.

named constant


Related study sets

American History 9: The Progressive Presidents and the start of WWI

View Set

Introduction to Sociology Section Quiz CH. 13

View Set

Chapter 12 Patterns of Inheritance

View Set

AP European History Elizabeth 1 outline

View Set

Ch. 28 - The Child with Cerebral Dysfunction

View Set