CS Homework 4

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

What will the following program segment display? int a = 0, b = 2, x = 4, y = 0; cout << (a == b) << " " << (a != y) << " " << (b <= x) << " " << (y > a) << endl;

0 0 1 0

The following if statements are equivalent: if (calls == 20) rate *= 0.5; if (calls = 20) rate *= 0.5;

false

The || operator performs ____________________ evaluation. If the sub-expression on the left side of an || operator is true, the sub-expression on the right side will not be checked because it is only necessary for one of the sub-expressions to be true for the whole expression to evaluate to true.

short circuit

The logical operator && means AND, the result of the operator is:

to connect two expressions into one. Both expressions must be true for the overall expression to be true

The logical operator || means OR, the result of the operator is:

to connect two expressions into one. One or both expressions must be true for the overall expression to be true. It is only necessary for one to be true, and it does not matter which

The logical operator ! means NOT, the result of the operator is:

to reverse the "truth" of an expression. It makes a true expression false, and a false expression true

Assuming x is 5, y is 6, and z is 8, indicate whether the following relational expression is true or false: (2 + x) != y

true

Assuming x is 5, y is 6, and z is 8, indicate whether the following relational expression is true or false: 7 <= (x + 2)

true

Assuming x is 5, y is 6, and z is 8, indicate whether the following relational expression is true or false: x <= (y * 2)

true

Assuming x is 5, y is 6, and z is 8, indicate whether the following relational expression is true or false: x == 5

true

Assuming x is 5, y is 6, and z is 8, indicate whether the following relational expression is true or false: x >= 0

true

Assuming x is 5, y is 6, and z is 8, indicate whether the following relational expression is true or false: z != 4

true

Assuming x is 5, y is 6, and z is 8, indicate whether the following relational expression is true or false: z > 4

true

The following if/else statements cause the same output to display. if (x > y) cout << "x is greater than y.\n"; else cout << "x is not greater than y.\n"; if (x <= y) cout << "x is not greater than y.\n"; else cout << "x is greater than y.\n";

true

The scope of a variable is limited to the block in which it is defined.

true


Set pelajaran terkait

BUS498- Strategic Management Exam 1

View Set

Chapter 45: Nursing Care of the Child With an Alteration in Tissue Integrity/Integumentary Disorder

View Set

GENERAL INSURANCE PRINCIPLES class3 INSURANCE PRODUCERS

View Set

aPHR test study guide - Compensation and Benefits (14%)

View Set

Introduction to Entrepreneurship Chapter 5 Quiz MindtapOpportunity identification

View Set

Programming Fundamental quiz 1-4

View Set

Chapter 07 - Membrane Structure and Function

View Set

ACSM chapter 3.4 specific anatomy part 3 (knee, ankle, foot, and spine)

View Set