Filters
Question type

Study Flashcards

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

A) True
B) False

Correct Answer

verifed

verified

The operators !, &&, and || are called relational operators.

A) True
B) False

Correct Answer

verifed

verified

Which of the following operators has the lowest precedence?


A) !
B) ||
C) &&
D) =

E) None of the above
F) B) and D)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

False

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 "____________________".

Correct Answer

verifed

verified

pass

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.

Correct Answer

verifed

verified

short-circ...

View Answer

You can disable assert statements by using which of the following?


A) #include <cassert>
B) #define <assert>
C) #clear NDEBUG
D) #define NDEBUG

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100.

A) True
B) False

Correct Answer

verifed

verified

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


A) false
B) true
C) 0
D) null

E) All of the above
F) B) and D)

Correct Answer

verifed

verified

Putting ____________________ in front of a logical expression reverses the value of that logical expression.

Correct Answer

verifed

verified

Which of the following is a relational operator?


A) =
B) ==
C) !
D) &&

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

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


A) if (x == 5)
B) if (x = 5)
C) if (x <= 5)
D) if (x >= 5)

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

What is the output of the following C++ code? What is the output of the following C++ code?   A)  2 B)  5 C)  8 D)  10


A) 2
B) 5
C) 8
D) 10

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

What is the output of the following C++ code? int x = 35; Int y = 45; Int z; If (x > y) Z = x + y; Else Z = y - x; Cout << x << " " << y << " " << z << endl;


A) 35 45 80
B) 35 45 10
C) 35 45 -10
D) 35 45 0

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

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;.


A) 2
B) 3
C) 4
D) 6

E) A) and C)
F) A) and B)

Correct Answer

verifed

verified

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


A) float, double
B) char, string
C) int, bool
D) float, string

E) C) and D)
F) A) and B)

Correct Answer

verifed

verified

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


A) section 2
B) section 3
C) section 4
D) section 5

E) B) and D)
F) All of the above

Correct Answer

verifed

verified

D

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


A) 2
B) 3
C) 4
D) 5

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

Showing 1 - 20 of 40

Related Exams

Show Answer