Deck 4: Making Decisions

ملء الشاشة (f)
exit full mode
سؤال
The C++ ________ operator represents logical AND.

A) ++
B) )AND.
C) ||
D) &
E) &&
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Relational operators allow you to ________ numbers.

A) add
B) multiply
C) compare
D) average
E) verify
سؤال
Which of the following correctly declares an enumerated data type named student?

A) enum student { Bill, Tom, Mary };
B) enum student { "Bill", "Tom", "Mary" };
C) int Bill = 1, Tom = 2, Mary = 3; enum student { 1, 2, 3 };
D) Any of the above 3 methods will work.
E) None of the above 3 methods will work.
سؤال
To check if a variable has a particular value, use the = relational operator, as in the statement
if (s = 3)
cout << "S has the value 3";
سؤال
Assuming goodData is a Boolean variable, the following two tests are logically equivalent.
if (goodData == false)
if (!goodData)
سؤال
In C++ when a relational expression is false, it has the value

A) 1.
B) 0.
C) -1.
D) "0".
E) of any negative number.
سؤال
The ________ statement executes one block of statements if a test condition is True, and another block if the condition is false.

A) if
B) if/else
C) if/else if
D) switch
E) trailing else
سؤال
A pair of characters or a pair of string objects can be compared with any of the relational operators.
سؤال
All of the relational operators are binary.
سؤال
logical operators AND and OR have a higher precedence than the NOT operator.
سؤال
The ________ operator takes an operand and reverses its truth or falsehood.

A) relational
B) &&
C) ||
D) !
E) !=
سؤال
If the sub-expression on the left side of an || operator is True, the expression on the right side will not be checked.
سؤال
A(n) ________ is a variable, usually a bool, that signals when a condition exists.

A) flag
B) identifier
C) named constant
D) condition variable
E) logical variable
سؤال
If a switch statement has no ________ statements, the program "falls through" all of the statements below the one with the matching case expression.

A) break
B) exit
C) case
D) default
E) relational
سؤال
A trailing else placed at the end of an if/else if statement provides a default action when ________ of the if conditions is/are True.

A) none
B) any one
C) only the last one
D) at least two
E) all
سؤال
The statement
pass = (score >= 7) ?
True : false;
does exactly the same thing as the if/else statement below:
if (score >= 7)
pass = True;
else
pass = false;
سؤال
The rule for matching an else with an if is that an else goes with the last if statement before it that doesn't have its own else.
سؤال
When an if statement is placed within the conditionally-executed code of another if statement, this is known as a(n)

A) complex if
B) overloaded if
C) nested if
D) conditional if
E) double if
سؤال
The ________ statement causes other program statements to execute only under certain conditions.

A) logical
B) relational
C) cin
D) cout
E) if
سؤال
The following C++ test checks if the variable child is in the range 3 to 12.
if (child >= 3 || child <= 12)
سؤال
The ________ operator is used in C++ to test for equality.

A) =
B) <>
C) &&
D) ==
E) ||
سؤال
Assuming moreData is a Boolean variable, the following two tests are logically equivalent.
if (moreData == True)
if (moreData)
سؤال
A flag is a variable, usually of data type ________, that signals whether or not some condition exists.

A) char
B) string
C) int
D) bool
E) logical
سؤال
The following C++ test checks if the variable child is in the range 3 - 12.
if (child >= 3 && <= 12)
سؤال
What will the following statement do if x equals 17 and answer = 20?
Answer = x > 100 ?
0 : 1;

A) Assign 0 to answer.
B) Assign 0 to x.
C) Assign 1 to answer.
D) Assign 1 to x.
E) Assign 17 to answer.
سؤال
The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement.

A) conditional test
B) break
C) trailing else
D) else if
E) body
سؤال
If s1 and s2 are string objects, s1 == s2 is True when

A) s1 = "lion" and s2 = "lioness".
B) s1 = "dog" and s2 = "DOG".
C) s1 = "cat" and s2 = "cat ".
D) None of these because in each case one or more characters in the strings have different ASCII codes.
E) None of these because string objects cannot be compared with relational operators.
سؤال
When a program lets the user know that an invalid menu choice has been made, this is an example of

A) input validation.
B) output validation.
C) menu reselection.
D) invalidation.
E) being user unfriendly.
سؤال
The scope of a variable is the program it is defined in.
سؤال
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/then
B) if/else
C) if/else if
D) if/not if
E) if/endif
سؤال
The expression x < y is called a(n) ________ expression.

A) arithmetic
B) logical
C) relational
D) comparison
E) binary
سؤال
Relational operators connect two or more relational expressions into one, or reverse the logic of an expression.
سؤال
The following statements will not print anything.
x = 5;
if (x < 5)
cout << "Hello ";
cout << "world \n";
سؤال
What will the following expression evaluate to?
!( 6 > 7 || 3 == 4)

A) 0
B) -1
C) 6
D) True
E) false
سؤال
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
B) if/else
C) if/else if
D) switch
E) if/endif
سؤال
The ________ operator is known as the logical OR operator.

A) !
B) &
C) &&
D) ||
E) //
سؤال
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.
سؤال
If the sub-expression on the left side of an && operator is True, the expression on the right side will not be checked.
سؤال
Relational expressions and logical expressions are both Boolean, which means they evaluate to True or false.
سؤال
An expression in a C++ if statement that evaluates to 5, -5, or for that matter anything other than 0, is considered True.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Making Decisions
1
The C++ ________ operator represents logical AND.

A) ++
B) )AND.
C) ||
D) &
E) &&
E
2
Relational operators allow you to ________ numbers.

A) add
B) multiply
C) compare
D) average
E) verify
C
3
Which of the following correctly declares an enumerated data type named student?

A) enum student { Bill, Tom, Mary };
B) enum student { "Bill", "Tom", "Mary" };
C) int Bill = 1, Tom = 2, Mary = 3; enum student { 1, 2, 3 };
D) Any of the above 3 methods will work.
E) None of the above 3 methods will work.
A
4
To check if a variable has a particular value, use the = relational operator, as in the statement
if (s = 3)
cout << "S has the value 3";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
Assuming goodData is a Boolean variable, the following two tests are logically equivalent.
if (goodData == false)
if (!goodData)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
In C++ when a relational expression is false, it has the value

A) 1.
B) 0.
C) -1.
D) "0".
E) of any negative number.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
The ________ statement executes one block of statements if a test condition is True, and another block if the condition is false.

A) if
B) if/else
C) if/else if
D) switch
E) trailing else
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
A pair of characters or a pair of string objects can be compared with any of the relational operators.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
All of the relational operators are binary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
logical operators AND and OR have a higher precedence than the NOT operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
The ________ operator takes an operand and reverses its truth or falsehood.

A) relational
B) &&
C) ||
D) !
E) !=
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
If the sub-expression on the left side of an || operator is True, the expression on the right side will not be checked.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
A(n) ________ is a variable, usually a bool, that signals when a condition exists.

A) flag
B) identifier
C) named constant
D) condition variable
E) logical variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
If a switch statement has no ________ statements, the program "falls through" all of the statements below the one with the matching case expression.

A) break
B) exit
C) case
D) default
E) relational
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
A trailing else placed at the end of an if/else if statement provides a default action when ________ of the if conditions is/are True.

A) none
B) any one
C) only the last one
D) at least two
E) all
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
The statement
pass = (score >= 7) ?
True : false;
does exactly the same thing as the if/else statement below:
if (score >= 7)
pass = True;
else
pass = false;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
The rule for matching an else with an if is that an else goes with the last if statement before it that doesn't have its own else.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
When an if statement is placed within the conditionally-executed code of another if statement, this is known as a(n)

A) complex if
B) overloaded if
C) nested if
D) conditional if
E) double if
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
The ________ statement causes other program statements to execute only under certain conditions.

A) logical
B) relational
C) cin
D) cout
E) if
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
The following C++ test checks if the variable child is in the range 3 to 12.
if (child >= 3 || child <= 12)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
The ________ operator is used in C++ to test for equality.

A) =
B) <>
C) &&
D) ==
E) ||
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
Assuming moreData is a Boolean variable, the following two tests are logically equivalent.
if (moreData == True)
if (moreData)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
A flag is a variable, usually of data type ________, that signals whether or not some condition exists.

A) char
B) string
C) int
D) bool
E) logical
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
The following C++ test checks if the variable child is in the range 3 - 12.
if (child >= 3 && <= 12)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
What will the following statement do if x equals 17 and answer = 20?
Answer = x > 100 ?
0 : 1;

A) Assign 0 to answer.
B) Assign 0 to x.
C) Assign 1 to answer.
D) Assign 1 to x.
E) Assign 17 to answer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement.

A) conditional test
B) break
C) trailing else
D) else if
E) body
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
If s1 and s2 are string objects, s1 == s2 is True when

A) s1 = "lion" and s2 = "lioness".
B) s1 = "dog" and s2 = "DOG".
C) s1 = "cat" and s2 = "cat ".
D) None of these because in each case one or more characters in the strings have different ASCII codes.
E) None of these because string objects cannot be compared with relational operators.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
When a program lets the user know that an invalid menu choice has been made, this is an example of

A) input validation.
B) output validation.
C) menu reselection.
D) invalidation.
E) being user unfriendly.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
The scope of a variable is the program it is defined in.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
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/then
B) if/else
C) if/else if
D) if/not if
E) if/endif
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
The expression x < y is called a(n) ________ expression.

A) arithmetic
B) logical
C) relational
D) comparison
E) binary
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
Relational operators connect two or more relational expressions into one, or reverse the logic of an expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
The following statements will not print anything.
x = 5;
if (x < 5)
cout << "Hello ";
cout << "world \n";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
What will the following expression evaluate to?
!( 6 > 7 || 3 == 4)

A) 0
B) -1
C) 6
D) True
E) false
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
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
B) if/else
C) if/else if
D) switch
E) if/endif
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
The ________ operator is known as the logical OR operator.

A) !
B) &
C) &&
D) ||
E) //
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
If the sub-expression on the left side of an && operator is True, the expression on the right side will not be checked.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
Relational expressions and logical expressions are both Boolean, which means they evaluate to True or false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
An expression in a C++ if statement that evaluates to 5, -5, or for that matter anything other than 0, is considered True.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.