Chapter 5 Review

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

The comparison operator representing "not equal" in C++ is _______.

!=

For a program to use the setprecision stream manipulator, it must contain the ______ directive.

#include <iomanip>

The symbol used in C++ for the And operator is _______.

&&

The condition below could be written as _____ ( num <= 10 )

( ( num < 10 ) && ( num = 10 ) )

Which of the following conditions would test to see if the variable number was equal to 29?

( number == 29 )

What would be the result of the following C++ code (assuming all necessary directives): double number = 1234.567; cout << scientific << number << endl;

1.234567e+03

What is the outcome of the following arithmetic expression in C++: 2 + 4 * 3

10

What is the outcome of the following arithmetic expression in C++: 2 * 4 + 4

12

What would be the result of the following C++ code (assuming all necessary directives): double number = 1234.567; cout << fixed << number << endl;

1234.567000

What would be the result of the following C++ code (assuming all necessary directives): double number = 1234.56; cout << fixed; cout << setprecision(0) cout << number << endl;

1235

The comparison operator representing "equal to" in C++ is ______.

==

________ refers to the process of verifying that the input data is within the expected range.

Data validation

Given the following code: int x = 1; int y = 2; int z = 3; Will the outcome of the condition in the if statement below be true or false? Show your evaluation breakdown. if ( ( x == 2 ) || ( y == 2 ) || ( z == 2 ) )

Evaluates to true

Another name for logical operators are comparison operators. (T or F)

False

By default in C++, smaller numbers with a decimal place (those containing six or fewer digits to the left of the decimal) are displayed in exponential notation. (T or F)

False

Comparison operators are also referred to as symbol operators.

False

The "Or" logical operator has a smaller precedence number than the "And" logical operator. (T or F)

False

The oval in a flowchart is the decision symbol (T or F)

False

The toupper function may have more than one argument. (T or F)

False

With short-circuit evaluation, each sub-condition is independent of any other sub-condition. (T or F)

False

Given the following code: int number = 49; What will be printed, if anything, and what will the value of the variable number be after the following statements are executed? if ( number >= 50 ) cout << "yes" << endl; number = number + 1;

It will display nothing, but still add to make 50

Although not required, it is good programming practice to use a comment (such as //end if) to mark the end of the if statement in a program. (T or F)

True

Another name for the selection structure is the decision structure. (T or F)

True

C++ provides stream manipulators that allow the programmer to control the format used to display real numbers. (T or F)

True

In the summary of operators, all arithmetic operators will be evaluated prior to any relational operators. (T or F)

True

In the summary of operators, logical operators will be evaluated after all relational operators. (T or F)

True

The "equal to" operator has a higher precedence number than the "less than" operator in C++. (T or F)

True

Without a specialized instruction, in order to swap the contents of two variables a third variable is needed. (T or F)

True

You should not use the equality operator or the equality operator or the inequality operator to compare two real numbers because not all real numbers can be stored precisely in memory. (T or F)

True

_______ tables summarize how the computer evaluates the logical operators in an expression.

Truth

What value is stored in the letter variable after the following? char letter = 'a'; char letter2 = ' '; letter2 = toupper(letter);

a

An item that appears between parentheses in a function's syntax is called a(n) _______.

argument

In a selection structure, if a path contains more than one statement, the statements must be entered as a statement block, which means they must be enclosed in a set of _______.

braces

What data type is required for the argument in the toupper and tolower functions?

char

C++ provides the _______ stream manipulator to display real numbers in exponential notation. a) data type c) scientific b) real d) none of the above

d

The ________ and ________ operators can be used interchangeably. a) &&, || c) *, / b)+, - d) none of the above

d

The ______ in a flowchart is called the decision symbol.

diamond

Selection structures that contain instructions on both the true and false paths are referred to as _______ selection structures.

dual-alternative

A selection structure's condition must evaluate to ______.

either true or false

In an if statement, you cannot have an else clause without a matching ______ clause.

if

Given the following code: int testScore = 0; cout << "Enter the test score: "; cin >> testScore; Write the if statement to print "yes" if the test score entered is valid, and "no" if it is not. A valid test score would be in the range from 0 to 100, inclusive (including 0 and 100).

if ( ( Test score >= 0 ) && ( Test score <= 100 ) ) cout << "Yes" << endl; else cout << "No" << endl;

Given the following code: char letter = ' '; cout << "Enter a letter: "; cin >> letter; Rewrite the following if statement without using the toupper function: if ( toupper(letter) = "X" ) cout << "The letter entered was either x or X" << endl;

if ( ( letter == 'x' ) || ( letter == 'X' ) ) cout << "The letter entered was either x or X" << endl;

Rewrite the following if statement condition without using the != operator. if ( number != 50 )

if ( ( number < 50 ) || ( number > 50 ) )

Write the if statement to print "yes" on the screen if the value stored in the variable number is between 1 and 100, exclusive (excluding 1 and 100).

if ( ( number > 1 ) && ( number < 100 ) ) cout << "Yes" << endl;

Write the if statement to print "yes" on the screen if the value stored in the value stored in the variable number is between 1 and 100, inclusive (including 1 and 100).

if ( ( number >= 1 ) && ( number <= 100 ) ) cout << "Yes" << endl;

Given the following code: int number = 50; Write the if statement to print "yes" and add one to the number variable if the value stored in the number variable is greater than or equal to 50.

if ( number >= 50 ) { number == number + 1; cout << "Yes" << endl; }

Stream manipulators that do not have arguments, such as fixed and scientific, are defined in the ______.

iomanip

A _______ variable is a variable that can be used only within the statements block in which it is declared.

local

Another name for comparison operators is _______ operators.

relational

You can use the _______ stream manipulator to control the number of decimal places that appear when a real number is displayed.

setprecision

With a condition that has sub-conditions, the concept of evaluating the second sub-condition based upon the result of the first sub-condition is referred to as ______.

short-circuit evaluation

A(n) ______ selection structure occurs when there are one or more actions to be taken only when its condition evaluates to true.

single-alternative

Logical operators combine ________.

two or more conditions


Kaugnay na mga set ng pag-aaral

CHAPTER 6 THE THREE ENERGY SYSTEMS WORKING TOGETHER TO PRODUCE ATP

View Set

chapter 16 - disability income insurance

View Set

CH_11_Skull and Cranial Bones (SELF-TEST)

View Set

pearson elemental geosystems ch 10

View Set