Deck 4: Control Structures I Selection

ملء الشاشة (f)
exit full mode
سؤال
Which of the following is a relational operator?

A) =
B) ==
C) !
D) &&
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The expression in an if statement is sometimes called a(n) ____.

A) selection statement
B) action statement
C) decision maker
D) action maker
سؤال
A compound statement functions as if it was a single statement.
سؤال
The operators != and == have the same order of precedence.
سؤال
In C++, both ! and != are relational operators.
سؤال
In C++, !, &&, and || are called relational operators.
سؤال
A control structure alters the normal sequential flow of execution in a program.
سؤال
The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100.
سؤال
In C++, && has a higher precedence than ||.
سؤال
What does <= mean?

A) less than
B) greater than
C) less than or equal to
D) greater than or equal to
سؤال
If the expression in an assert statement evaluates to true, the program terminates.
سؤال
Which of the following expressions correctly determines that x is greater than 10 and less than 20?

A) 10 < x < 20
B) (10 < x < 20)
C) 10 < x && x < 20
D) 10 < x || x < 20
سؤال
Which of the following operators has the highest precedence?

A) !
B) *
C) %
D) =
سؤال
In a ____ control structure, the computer executes particular statements depending on some condition(s).

A) looping
B) repetition
C) selection
D) sequence
سؤال
Which of the following is the "not equal to" relational operator?

A) !
B) |
C) !=
D) &
سؤال
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
سؤال
The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable.
سؤال
Which of the following operators has the lowest precedence?

A) !
B) ||
C) &&
D) =
سؤال
Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true.
سؤال
Suppose that x is an int variable. Which of the following expressions always evaluates to true?

A) (x > 0) || ( x <= 0)
B) (x >= 0) || (x == 0)
C) (x > 0) && ( x <= 0)
D) (x > 0) && (x == 0)
سؤال
To develop a program, you can use an informal mixture of C++ and ordinary language, called ____.

A) assert code
B) pseudocode
C) cppcode
D) source code
سؤال
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
سؤال
Putting ____________________ in front of a logical expression reverses the value of that logical expression.
سؤال
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
سؤال
What is the output of the following C++ code? int x = 55;
Int y = 5;
Switch (x % 7)
{
Case 0:
Case 1:
Y++;
Case 2:
Case 3:
Y = y + 2;
Case 4:
Break;
Case 5:
Case 6:
Y = y - 3;
}
Cout << y << endl;

A) 2
B) 5
C) 8
D) 10
سؤال
In C++, the logical operator AND is represented by ____________________.
سؤال
The symbol > is a(n) ____________________ operator.
سؤال
What is the output of the following code? char lastInitial = 'A';
Switch (lastInitial)
{
Case 'A':
Cout << "section 1" <Break;
Case 'B':
Cout << "section 2" <Break;
Case 'C':
Cout << "section 3" <Break;
Case 'D':
Cout << "section 4" <Break;
Default:
Cout << "section 5" <}

A) section 1
B) section 2
C) section 3
D) section 5
سؤال
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
سؤال
The conditional operator ?: takes ____ arguments.

A) two
B) three
C) four
D) five
سؤال
When one control statement is located within another, it is said to be ____.

A) blocked
B) compound
C) nested
D) closed
سؤال
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)
سؤال
The appearance of = in place of == resembles a(n) ____.

A) syntax error
B) silent killer
C) compilation error
D) input failure
سؤال
A ____________________ operator allows you to make comparisions in a program.
سؤال
You can disable assert statements by using which of the following?

A) #include
B) #define
C) #clear NDEBUG
D) #define NDEBUG
سؤال
What is the output of the following code fragment if the input value is 4? int num;
Int alpha = 10;
Cin >> num;
Switch (num)
{
Case 3:
Alpha++;
Break;
Case 4:
Case 6:
Alpha = alpha + 3;
Case 8:
Alpha = alpha + 4;
Break;
Default:
Alpha = alpha + 5;
}
Cout << alpha << endl;

A) 13
B) 14
C) 17
D) 22
سؤال
The value of the expression 7 + 8 <= 15 is ____________________.
سؤال
What is the output of the following code? if (6 > 8)
{
Cout << " ** " << endl ;
Cout << "****" << endl;
}
Else if (9 == 4)
Cout << "***" << endl;
Else
Cout << "*" << endl;

A) *
B) **
C) ***
D) ****
سؤال
For a program to use the assert function, it must include which of the following?

A) #include
B) #include
C) #include
D) #include NDEBUG
سؤال
What is the output of the following code? char lastInitial = 'S';
Switch (lastInitial)
{
Case 'A':
Cout << "section 1" <Break;
Case 'B':
Cout << "section 2" <Break;
Case 'C':
Cout << "section 3" <Break;
Case 'D':
Cout << "section 4" <Break;
Default:
Cout << "section 5" <}

A) section 2
B) section 3
C) section 4
D) section 5
سؤال
Every else must be paired with a(n) ____________________.
سؤال
Suppose found = true and num = 6. The value of the expression (!found) || (num > 6) is ____________________.
سؤال
A(n) ____________________ structure does not require the evaluation of a logical expression.
سؤال
The ____________________ of relational and logical operators is said to be from left to right.
سؤال
Putting a semicolon after the parentheses following the expression in an if statement (that is, before the statement) is a(n) ____________________ error.
سؤال
To output results correctly, the switch structure must include a(n) ____________________ statement after each cout statement, except the last cout statement.
سؤال
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.
سؤال
The value of the expression 6 < 5 || 'g' > 'a' && 7 < 4
is ____________________.
سؤال
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 "____________________".
سؤال
Once an input stream enters a(n) ____________________ state, all subsequent input statements associated with that input stream are ignored, and the computer continues to execute the program, which produces erroneous results.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Control Structures I Selection
1
Which of the following is a relational operator?

A) =
B) ==
C) !
D) &&
B
2
The expression in an if statement is sometimes called a(n) ____.

A) selection statement
B) action statement
C) decision maker
D) action maker
C
3
A compound statement functions as if it was a single statement.
True
4
The operators != and == have the same order of precedence.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
In C++, both ! and != are relational operators.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
In C++, !, &&, and || are called relational operators.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
A control structure alters the normal sequential flow of execution in a program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
In C++, && has a higher precedence than ||.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
What does <= mean?

A) less than
B) greater than
C) less than or equal to
D) greater than or equal to
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
If the expression in an assert statement evaluates to true, the program terminates.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following expressions correctly determines that x is greater than 10 and less than 20?

A) 10 < x < 20
B) (10 < x < 20)
C) 10 < x && x < 20
D) 10 < x || x < 20
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following operators has the highest precedence?

A) !
B) *
C) %
D) =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
In a ____ control structure, the computer executes particular statements depending on some condition(s).

A) looping
B) repetition
C) selection
D) sequence
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following is the "not equal to" relational operator?

A) !
B) |
C) !=
D) &
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following operators has the lowest precedence?

A) !
B) ||
C) &&
D) =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
Suppose that x is an int variable. Which of the following expressions always evaluates to true?

A) (x > 0) || ( x <= 0)
B) (x >= 0) || (x == 0)
C) (x > 0) && ( x <= 0)
D) (x > 0) && (x == 0)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
To develop a program, you can use an informal mixture of C++ and ordinary language, called ____.

A) assert code
B) pseudocode
C) cppcode
D) source code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
Putting ____________________ in front of a logical expression reverses the value of that logical expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
What is the output of the following C++ code? int x = 55;
Int y = 5;
Switch (x % 7)
{
Case 0:
Case 1:
Y++;
Case 2:
Case 3:
Y = y + 2;
Case 4:
Break;
Case 5:
Case 6:
Y = y - 3;
}
Cout << y << endl;

A) 2
B) 5
C) 8
D) 10
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
In C++, the logical operator AND is represented by ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
The symbol > is a(n) ____________________ operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
What is the output of the following code? char lastInitial = 'A';
Switch (lastInitial)
{
Case 'A':
Cout << "section 1" <Break;
Case 'B':
Cout << "section 2" <Break;
Case 'C':
Cout << "section 3" <Break;
Case 'D':
Cout << "section 4" <Break;
Default:
Cout << "section 5" <}

A) section 1
B) section 2
C) section 3
D) section 5
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
The conditional operator ?: takes ____ arguments.

A) two
B) three
C) four
D) five
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
When one control statement is located within another, it is said to be ____.

A) blocked
B) compound
C) nested
D) closed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
The appearance of = in place of == resembles a(n) ____.

A) syntax error
B) silent killer
C) compilation error
D) input failure
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
A ____________________ operator allows you to make comparisions in a program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
You can disable assert statements by using which of the following?

A) #include
B) #define
C) #clear NDEBUG
D) #define NDEBUG
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
What is the output of the following code fragment if the input value is 4? int num;
Int alpha = 10;
Cin >> num;
Switch (num)
{
Case 3:
Alpha++;
Break;
Case 4:
Case 6:
Alpha = alpha + 3;
Case 8:
Alpha = alpha + 4;
Break;
Default:
Alpha = alpha + 5;
}
Cout << alpha << endl;

A) 13
B) 14
C) 17
D) 22
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
The value of the expression 7 + 8 <= 15 is ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
What is the output of the following code? if (6 > 8)
{
Cout << " ** " << endl ;
Cout << "****" << endl;
}
Else if (9 == 4)
Cout << "***" << endl;
Else
Cout << "*" << endl;

A) *
B) **
C) ***
D) ****
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
For a program to use the assert function, it must include which of the following?

A) #include
B) #include
C) #include
D) #include NDEBUG
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
What is the output of the following code? char lastInitial = 'S';
Switch (lastInitial)
{
Case 'A':
Cout << "section 1" <Break;
Case 'B':
Cout << "section 2" <Break;
Case 'C':
Cout << "section 3" <Break;
Case 'D':
Cout << "section 4" <Break;
Default:
Cout << "section 5" <}

A) section 2
B) section 3
C) section 4
D) section 5
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
Every else must be paired with a(n) ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
Suppose found = true and num = 6. The value of the expression (!found) || (num > 6) is ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
A(n) ____________________ structure does not require the evaluation of a logical expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
The ____________________ of relational and logical operators is said to be from left to right.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
Putting a semicolon after the parentheses following the expression in an if statement (that is, before the statement) is a(n) ____________________ error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
To output results correctly, the switch structure must include a(n) ____________________ statement after each cout statement, except the last cout statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
The value of the expression 6 < 5 || 'g' > 'a' && 7 < 4
is ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
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 "____________________".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
Once an input stream enters a(n) ____________________ state, all subsequent input statements associated with that input stream are ignored, and the computer continues to execute the program, which produces erroneous results.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.