CPSC 1020 - Chapter 4

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What will the following statement do if x equals 17 and answer = 20? answer = x > 100 ? 0 : 1; A. Assign 1 to answer. B. Assign 1 to x. C. Assign 17 to answer. D. Assign 0 to x. E. Assign 0 to answer.

A. Assign 1 to answer.

If s1 and s2 are string objects, s1 == s2 is true when A. None of these because string objects cannot be compared with relational operators. B. s1 = "dog" and s2 = "DOG". C. None of these because in each case one or more characters in the strings have different ASCII codes. D. s1 = "cat" and s2 = "cat ". E. s1 = "lion" and s2 = "lioness".

A. None of these because string objects cannot be compared with relational operators.

The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement. A. trailing else B. conditional test C. break D. body E. else if

A. trailing else

The ________ statement executes one statement, or block of statements, if a condition is true and skips it, doing nothing, if the condition is false. A. if/endif B. if C. if/else if D. if/else E. switch

B. if

When a program lets the user know that an invalid menu choice has been made, this is an example of A. being user unfriendly B. input validation C. menu reselection D. output validation E. invalidation

B. input validation

The ________ statement acts like a chain of if statements. Each performs its test, one after the other, until one of them is found to be true or until the construct is exited without any test ever evaluating to true. A. if/endif B. if/not if C. if/else if D. if/else E. if/then

C. if/else if

The ________ operator is used in C++ to test for equality. A. <> B. && C. | | D. == E. =

D. ==

The expression x < y is called a(n) ________ expression. A. comparison B. arithmetic C. logical D. relational E. binary

D. relational

What will the following expression evaluate to? !( 6 > 7 || 3 == 4) A. -1 B. false C. 6 D. true E. 0

D. true

True/False: If the sub-expression on the left side of an && operator is true, the expression on the right side will not be checked.

False

True/False: Relational operators connect two or more relational expressions into one, or reverse the logic of an expression.

False

True/False: The following C++ test checks if the variable child is in the range 3 - 12. if (child >= 3 && <= 12)

False

True/False: The following statements will not print anything. x = 5; if (x < 5) count << "Hello "; court << "world /n";

False

True/False: A switch statement branches to a particular block of code depending on the value of a numeric (i.e. integer or floating-point) variable or constant.

True

True/False: An expression in a C++ if statement that evaluates to 5, -5, or for that matter anything other than 0, is considered true.

True

True/False: Relational expressions and logical expressions are both Boolean, which means they evaluate to true or false.

True

True/False: The scope of a variable is the program it is defined in.

True

True/False: Assuming moreData is a Boolean variable, the following two tests are logically equivalent. if (moreData == true) if (moreData)

true


संबंधित स्टडी सेट्स

Chapter 11: Healthcare Delivery Systems

View Set

Chapter 13- Geography (Earth Science)

View Set

history chapter 7 lesson 1;trish

View Set

ECON 104 EXAM 2, econ 104 exam 3, Econ 104 exam 1

View Set