Deck 4: Selection

ملء الشاشة (f)
exit full mode
سؤال
The term "flow of control" refers to the order in which a program's statements are executed.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
A relational expression consists of a boolean operator that compares two operands.
سؤال
In C, relational expressions are evaluated to yield a boolean result.
سؤال
In C, character data cannot be compared using relational operators.
سؤال
The && operator has a right-to-left associativity.
سؤال
The evaluation feature for the && and || operators that makes the evaluation of an expression stop as soon as it is definitively determined that an expression is true or false is known as short-circuit evaluation.
سؤال
The ! operator is an unary operator.
سؤال
The expression:
(6 * 3 == 36 / 2) && (13 < 3 * 3 + 4) || !(6 - 2 < 5)
evaluates to 1.
سؤال
The simplest C selection statement is the one-way if statement.
سؤال
The use of braces to enclose a set of individual statements creates a single block of statements, which may be used anywhere in a C program in place of a single statement.
سؤال
In C any expression can be tested within a selection statement, be it a relational, arithmetic, or assignment expression, or even a function call.
سؤال
Within a selection statement, an expression that evaluates to 0 or less is considered as false, while any positive is considered as true.
سؤال
A common practice for some programmers is to place the opening brace of a compound statement on the same line as the if and else statements.
سؤال
The following statement prints "You lose!" on the screen;
int num = -1;
if (num)
printf("Bingo!");
else
printf("You lose!");
سؤال
If you inadvertently use an assignment symbol, =, in place of the relational symbol, == in a relational expression, the compiler will flag this with either a warning or error message.
سؤال
Generally, the most useful nested if statement occurs when a second if-else statement is placed within the else part of an if-else statement.
سؤال
A nested if construction in which each nested if is written in the same line as the previous else is called an if-else chain, and is used extensively in many programming problems.
سؤال
Indentation used within an if-else is critical to ensure that the code compiles correctly.
سؤال
The compiler will, by default, associate an else with the closest previous unpaired if, unless braces are used to alter this default pairing.
سؤال
One of the main advantages of using a switch statement is that it avoids using the equality operator, ==.
سؤال
One of the main disadvantages of using a switch statement is that it requires the use of braces for compound internal statements.
سؤال
The switch statement usually results in more complex code than an equivalent if-else chain.
سؤال
Any number of case labels may be contained within a switch statement, in any order.
سؤال
In a switch statement, if the break statements are omitted, all cases following the matching case value, including the default case, are executed.
سؤال
When an executing program encounters a(n) ____ statement, the condition is evaluated to determine its numerical value, which is then interpreted as either true or false.

A)switch
B)break
C)if
D)else
سؤال
Relational expressions are also known as ____.

A)conditions
B)boolean expressions
C)logical expressions
D)if-else expressions
سؤال
The logical AND operator is ____.

A)||
B)&&
C)!
D)%%
سؤال
The logical NOT operator is ____.

A)||
B)&&
C)!
D)%%
سؤال
When the ____ operator is used with two expressions, the condition is true only if both expressions are true by themselves.

A)||
B)&&
C)!
D)%%
سؤال
When the ____ operator is used with two expressions, the resulting condition is true if either one or both of the two expressions are true.

A)||
B)&&
C)!
D)%%
سؤال
The ____ operator is used to change an expression to its opposite state.

A)||
B)&&
C)!
D)%%
سؤال
Which of the following operators has right to left associativity?

A)!
B)*
C)&&
D)||
سؤال
A ____ statement is one or more statements contained between braces.

A)conditional
B)nested
C)flow
D)compound
سؤال
What will the following program print on screen?
Int age = 0;
If (age = 40)
Printf("Happy Birthday!");
Else
Printf("Sorry");

A)Happy Birthday!
B)Sorry
C)Runtime error.
D)Nothing; the program will not compile.
سؤال
What will the following program print on screen?
Int age = 40;
If (age = 40)
Printf("Happy Birthday!");
Else
Printf("Sorry");

A)Happy Birthday!
B)Sorry
C)Runtime error.
D)Nothing; the program will not compile.
سؤال
What will the following program print on screen?
Int tenure = -5;
If (tenure + 5)
Printf("Congratulations!");
Else
Printf("Sorry");

A)Congratulations!
B)Sorry
C)Runtime error.
D)Nothing; the program will not compile.
سؤال
What will the following program print on screen?
Int tenure = -10;
If (tenure + 5)
Printf("Congratulations!");
Else
Printf("Sorry");

A)Congratulations!
B)Sorry
C)Runtime error.
D)Nothing; the program will not compile.
سؤال
The use of ____ in a C program will result in a compiler error.

A)if (age == 40)
B)if (40 == age)
C)if (age = 40)
D)if (40 = age)
سؤال
Including one or more if-else statements within an if or if-else statement is referred to as a ____ if statement.

A)compound
B)nested
C)multiway
D)short-circuit
سؤال
A ____ statement is a specialized selection statement that can be used in place of an if-else chain where exact equality to one or more integer constants is required.

A)case
B)break
C)switch
D)nested if
سؤال
In a switch statement, the word ____ is optional and operates the same as the last else in an if-else chain.

A)if
B)break
C)case
D)default
سؤال
It is a good practice to terminate the last case in a switch statement with a ____.

A)switch
B)break
C)default
D)case
سؤال
One aspect of ____ programming is to check for improper data before an attempt is made to process it further.

A)defensive
B)extreme
C)robust
D)user-friendly
سؤال
____ is not a relational operator.

A) ==
B) >
C) !=
D) ||
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/44
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Selection
1
The term "flow of control" refers to the order in which a program's statements are executed.
True
2
A relational expression consists of a boolean operator that compares two operands.
False
3
In C, relational expressions are evaluated to yield a boolean result.
False
4
In C, character data cannot be compared using relational operators.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
5
The && operator has a right-to-left associativity.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
6
The evaluation feature for the && and || operators that makes the evaluation of an expression stop as soon as it is definitively determined that an expression is true or false is known as short-circuit evaluation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
7
The ! operator is an unary operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
8
The expression:
(6 * 3 == 36 / 2) && (13 < 3 * 3 + 4) || !(6 - 2 < 5)
evaluates to 1.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
9
The simplest C selection statement is the one-way if statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
10
The use of braces to enclose a set of individual statements creates a single block of statements, which may be used anywhere in a C program in place of a single statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
11
In C any expression can be tested within a selection statement, be it a relational, arithmetic, or assignment expression, or even a function call.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
12
Within a selection statement, an expression that evaluates to 0 or less is considered as false, while any positive is considered as true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
13
A common practice for some programmers is to place the opening brace of a compound statement on the same line as the if and else statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
14
The following statement prints "You lose!" on the screen;
int num = -1;
if (num)
printf("Bingo!");
else
printf("You lose!");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
15
If you inadvertently use an assignment symbol, =, in place of the relational symbol, == in a relational expression, the compiler will flag this with either a warning or error message.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
16
Generally, the most useful nested if statement occurs when a second if-else statement is placed within the else part of an if-else statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
17
A nested if construction in which each nested if is written in the same line as the previous else is called an if-else chain, and is used extensively in many programming problems.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
18
Indentation used within an if-else is critical to ensure that the code compiles correctly.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
19
The compiler will, by default, associate an else with the closest previous unpaired if, unless braces are used to alter this default pairing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
20
One of the main advantages of using a switch statement is that it avoids using the equality operator, ==.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
21
One of the main disadvantages of using a switch statement is that it requires the use of braces for compound internal statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
22
The switch statement usually results in more complex code than an equivalent if-else chain.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
23
Any number of case labels may be contained within a switch statement, in any order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
24
In a switch statement, if the break statements are omitted, all cases following the matching case value, including the default case, are executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
25
When an executing program encounters a(n) ____ statement, the condition is evaluated to determine its numerical value, which is then interpreted as either true or false.

A)switch
B)break
C)if
D)else
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
26
Relational expressions are also known as ____.

A)conditions
B)boolean expressions
C)logical expressions
D)if-else expressions
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
27
The logical AND operator is ____.

A)||
B)&&
C)!
D)%%
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
28
The logical NOT operator is ____.

A)||
B)&&
C)!
D)%%
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
29
When the ____ operator is used with two expressions, the condition is true only if both expressions are true by themselves.

A)||
B)&&
C)!
D)%%
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
30
When the ____ operator is used with two expressions, the resulting condition is true if either one or both of the two expressions are true.

A)||
B)&&
C)!
D)%%
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
31
The ____ operator is used to change an expression to its opposite state.

A)||
B)&&
C)!
D)%%
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
32
Which of the following operators has right to left associativity?

A)!
B)*
C)&&
D)||
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
33
A ____ statement is one or more statements contained between braces.

A)conditional
B)nested
C)flow
D)compound
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
34
What will the following program print on screen?
Int age = 0;
If (age = 40)
Printf("Happy Birthday!");
Else
Printf("Sorry");

A)Happy Birthday!
B)Sorry
C)Runtime error.
D)Nothing; the program will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
35
What will the following program print on screen?
Int age = 40;
If (age = 40)
Printf("Happy Birthday!");
Else
Printf("Sorry");

A)Happy Birthday!
B)Sorry
C)Runtime error.
D)Nothing; the program will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
36
What will the following program print on screen?
Int tenure = -5;
If (tenure + 5)
Printf("Congratulations!");
Else
Printf("Sorry");

A)Congratulations!
B)Sorry
C)Runtime error.
D)Nothing; the program will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
37
What will the following program print on screen?
Int tenure = -10;
If (tenure + 5)
Printf("Congratulations!");
Else
Printf("Sorry");

A)Congratulations!
B)Sorry
C)Runtime error.
D)Nothing; the program will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
38
The use of ____ in a C program will result in a compiler error.

A)if (age == 40)
B)if (40 == age)
C)if (age = 40)
D)if (40 = age)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
39
Including one or more if-else statements within an if or if-else statement is referred to as a ____ if statement.

A)compound
B)nested
C)multiway
D)short-circuit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
40
A ____ statement is a specialized selection statement that can be used in place of an if-else chain where exact equality to one or more integer constants is required.

A)case
B)break
C)switch
D)nested if
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
41
In a switch statement, the word ____ is optional and operates the same as the last else in an if-else chain.

A)if
B)break
C)case
D)default
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
42
It is a good practice to terminate the last case in a switch statement with a ____.

A)switch
B)break
C)default
D)case
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
43
One aspect of ____ programming is to check for improper data before an attempt is made to process it further.

A)defensive
B)extreme
C)robust
D)user-friendly
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
44
____ is not a relational operator.

A) ==
B) >
C) !=
D) ||
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.