Exam 4: Control Structures I Selection

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

A control structure alters the normal sequential flow of execution in a program.

(True/False)
4.8/5
(37)

Which of the following will cause a logical error if you are attempting to compare x to 5?

(Multiple Choice)
4.9/5
(36)

Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true.

(True/False)
4.8/5
(29)

Once an input stream enters a(n) ____________________ state, all subsequent input statements associated with that input stream are ignored, and the computer continues to execute the program, which produces erroneous results.

(Short Answer)
4.8/5
(40)

What is the value of x after the following statements execute? int x; X = (5 <= 3 && 'A' < 'F') ? 3 : 4

(Multiple Choice)
4.9/5
(41)

Suppose x is 5 and y is 7. Choose the value of the following expression: (x != 7) && (x <= y)

(Multiple Choice)
4.9/5
(36)

The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable.

(True/False)
4.8/5
(45)

Assume you have three int variables: x = 2, y = 6, and z. Choose the value of z in the following expression: z = (y / x > 0) ? x : y;.

(Multiple Choice)
4.8/5
(43)

The ____________________ of relational and logical operators is said to be from left to right.

(Short Answer)
4.8/5
(30)

The term ____________________ describes a process in which the computer evaluates a logical expression from left to right and stops as soon as the value of the expression is known.

(Short Answer)
4.7/5
(29)

What is the output of the following code? char lastInitial = 'S'; Switch (lastInitial) { case 'A': \quad cout << "section 1" << endl; \quad break; case 'B': \quad cout << "section 2" << endl; \quad break; case 'C': \quad cout << "section 3" << endl; \quad break; case 'D': \quad cout << "section 4" << endl; \quad break; default: \quad cout << "section 5" << endl; }

(Multiple Choice)
4.8/5
(39)

Consider the following statements. int score; string grade; if (score >= 65) grade = "pass"; else grade = "fail"; If score is equal to 75, the value of grade is "____________________".

(Short Answer)
4.7/5
(36)

If the expression in an assert statement evaluates to true, the program terminates.

(True/False)
4.7/5
(46)

Which of the following expressions correctly determines that x is greater than 10 and less than 20?

(Multiple Choice)
4.8/5
(39)

The value of the expression 6 < 5 || 'g' > 'a' && 7 < 4 is ____________________.

(Short Answer)
4.8/5
(33)

In C++, both ! and != are relational operators.

(True/False)
4.9/5
(41)

Suppose that x is an int variable. Which of the following expressions always evaluates to true?

(Multiple Choice)
4.8/5
(36)

The conditional operator ?: takes ____ arguments.

(Multiple Choice)
4.9/5
(34)

A compound statement functions as if it was a single statement.

(True/False)
5.0/5
(27)

The expression in an if statement is sometimes called a(n) ____.

(Multiple Choice)
4.7/5
(37)
Showing 21 - 40 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)