COSC 1336 Chapter 4 Decisions Quiz Part B

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

This operator takes an operand and reverses its truth or falsehood:

!

Which of the following is evaluated first, given the expression: A && B | | C && !D

!D

This operator represents the logical AND:

&&

When a relational expression is FALSE, it has the value

0

What is assigned to the variable result given the statement below with the following assumptions: x = 10, y = 7, and x, result, and y are all int variables. result = x >=y;

1

What is the output of the following segment of code if the value 4 is input by the user? int num; int total = 0; coutn<< "Enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: total = 1; case 2: total = 5; case 3: total = 10; case 4: total = total + 3; case 8: total = total + 6; default: total = total + 4; } cout << total << endl; }

13

What is the output of the following segment of code if the value 4 is input by the user? int num; int total = 0; cout<< "Enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: total = 1; break; case 2: total = 5; break; case 3: total = 10; break; case 4: total = total + 3; break; case 8: total = total + 6; break; default: total = total + 4; } cout << total << endl; }

3

Which value can be entered into the following code segment to display the message "That number is acceptable"? int number; cin >> number; if (number > 10 && number < 100) cout << "That number is acceptable. \n"; else cout << "That number is not acceptable. \n";

99

The __________ is an equality (or comparison) operator.

==

Given the if/else statement if (a < 5) b = 12; else d = 30;

a < 5 ? b = 12 : d = 30;

Without this statement appearing in a switch construct, the program " falls thorugh" all of the statements below the one with the matching case expression.

break

What is the value of the following expression? true && false

false

Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 int main () 4 { 5 int number = 5; 6 if (number >= 0 && <= 100) 7 cout << "passed. \n"; 8 else 9 cout << "failed. \n"; 10 return 0; 11 }

line 6

These operators connect two or more relational expressions into one, or reverse the logic of an expression.

logical

Given the following code segment, what is the output? int x = 1, y = 1, z = 1; y = y + z; x = x + y; cout << "result = " << (x < y ? y : x) << endl;

result = 3

The default section of a switch statement performs a similar task similar to the __________ portion of an if/else if statement.

trailing else

What is the value of the following expressin? true && !false

true

What is the value of the following expression? true && true

true

What is the value of the following expression? true | | false

true

Which of the following expressions will determine whether x is less than or equal to y?

x <= y

This operator represents the logical OR:

| |


Set pelajaran terkait

Chapter 24: Caring for the Patient with Spinal Cord Injuries Kathleen

View Set

VA DMVDangerous Driving Behaviors

View Set

Ethical Standards and Principles of Psychology

View Set

Amirkhan must finish this summer!!!

View Set

Insurance Terms and Related Concepts

View Set