Deck 3: More Flow of Control
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/45
العب
ملء الشاشة (f)
Deck 3: More Flow of Control
1
A switch statement variable must be ________
an integer, bool, char or enumerated type
2
It is illegal to make function calls inside a switch statement.
False
3
A function may return a boolean value.
True
4
The code following the ________ case is executed if none of the other cases are matched in a switch statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
5
A ____________ expression is an expression that can be thought of as being true or false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
6
The break statement causes all loops to exit.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
7
All switch statements can be converted into nested if-else statements
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
8
A break statement in a switch stops your program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which boolean operation is described by the following table?

A) or
B) and
C) not
D) none of the above

A) or
B) and
C) not
D) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
10
A _________ loop always executes the loop body at least once, irregardless of the loop condition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
11
A loop that iterates one too many or one too few times is said to be ________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
12
All nested if-else statements can be converted into switch statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
13
Variables defined inside a set of braces are said to be _______ to that block of code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
14
A compound statement that contains variable declarations is called a __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
15
_________ is a type whose values are defined by a list of constants of type int.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
16
Each repetition of a loop body is called ____________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
17
A semicolon by itself is a valid C++ statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
18
A boolean expression may evaluate to more than 2 values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
19
The compiler always pairs an else with _______________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
20
In an enumerated data type, different constants may not have the same value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
21
If a programming language does not use short-circuit evaluation, what is the output of the following code fragment if the value of myInt is 0?
Int other=3, myInt;
IfmyInt !=0 && other % myInt !=0)
Cout << "other is odd\n";
Else
Cout << "other is even\n";
A) other is even
B) other is odd
C) 0
D) run-time error, no output
Int other=3, myInt;
IfmyInt !=0 && other % myInt !=0)
Cout << "other is odd\n";
Else
Cout << "other is even\n";
A) other is even
B) other is odd
C) 0
D) run-time error, no output
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
22
What is the value of the following expression?
True && 4/3 || !6)))
A) true
B) false
C) 0
D) illegal syntax
True && 4/3 || !6)))
A) true
B) false
C) 0
D) illegal syntax
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
23
What is the output of the following code fragment?
Int x=0;
{
Int x=13;
Cout << x <<",";
}
Cout << x << endl;
A) 13,13
B) 0,13
C) 13,0
D) nothing, there is a syntax error.
Int x=0;
{
Int x=13;
Cout << x <<",";
}
Cout << x << endl;
A) 13,13
B) 0,13
C) 13,0
D) nothing, there is a syntax error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
24
Given the following code, what is the final value of i?
Int i;
Fori=0; i<=4;i++)
{
Cout << i << endl;
}
A) 3
B) 4
C) 5
D) 0
Int i;
Fori=0; i<=4;i++)
{
Cout << i << endl;
}
A) 3
B) 4
C) 5
D) 0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which of the following symbols has the highest precedence?
A) ++
B) ||
C) &&
D) -
A) ++
B) ||
C) &&
D) -
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
26
Given the following enumerated data type definition, what is the value of SAT?
Enum myType{SUN=3,MON=1,TUE=3,WED,THUR,FRI,SAT,NumDays};
A) 7
B) 6
C) 8
D) 5
E) unknown
Enum myType{SUN=3,MON=1,TUE=3,WED,THUR,FRI,SAT,NumDays};
A) 7
B) 6
C) 8
D) 5
E) unknown
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
27
What is the output of the following code fragment?
{
Int x=13;
Cout << x <<",";
}
Cout << x << endl;
A) 13,13
B) 0,13
C) 13,0
D) nothing, there is a syntax error.
{
Int x=13;
Cout << x <<",";
}
Cout << x << endl;
A) 13,13
B) 0,13
C) 13,0
D) nothing, there is a syntax error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
28
What is wrong with the following switch statement?
Int ans;
Cout <<"Type y for yes on n for no\n";
Cin >> ans;
Switch ans)
{
Case 'y':
Case 'Y': cout << "You said yes\n"; break;
Case 'n':
Case 'N': cout << "You said no\n"; break;
Default: cout <<"invalid answer\n";
}
A) ans is a int
B) break; is illegal syntax
C) nothing
D) there are no break statements on 2 cases.
Int ans;
Cout <<"Type y for yes on n for no\n";
Cin >> ans;
Switch ans)
{
Case 'y':
Case 'Y': cout << "You said yes\n"; break;
Case 'n':
Case 'N': cout << "You said no\n"; break;
Default: cout <<"invalid answer\n";
}
A) ans is a int
B) break; is illegal syntax
C) nothing
D) there are no break statements on 2 cases.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
29
Given the following enumerated data type definition, what is the value of SAT?
Enum myType{SUN,MON,TUE,WED,THUR,FRI,SAT,NumDays};
A) 7
B) 6
C) 8
D) 5
E) unknown
Enum myType{SUN,MON,TUE,WED,THUR,FRI,SAT,NumDays};
A) 7
B) 6
C) 8
D) 5
E) unknown
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which of the following boolean expressions tests to see if x is between 2 and 15 including 2 and 15)?
A) x<=15 || x>=2)
B) 2 <=x || x <=15)
C) x >=2 && x <=15)
D) 2 <= x <= 15)
A) x<=15 || x>=2)
B) 2 <=x || x <=15)
C) x >=2 && x <=15)
D) 2 <= x <= 15)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
31
Which boolean operation is described by the following table?

A) or
B) and
C) not
D) none of the above

A) or
B) and
C) not
D) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
32
What is the value of x after the following code executes?
Int x=10;
Ifx++ >10)
{
X =13;
}
A) 10
B) 9
C) 13
D) 11
Int x=10;
Ifx++ >10)
{
X =13;
}
A) 10
B) 9
C) 13
D) 11
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
33
What is the output of the following code fragment if x is 15?
Ifx < 20)
Ifx <10)
Cout << "less than 10 ";
Else
Cout << "large\n";
A) less than 10
B) nothing
C) large
D) no output, syntax error
Ifx < 20)
Ifx <10)
Cout << "less than 10 ";
Else
Cout << "large\n";
A) less than 10
B) nothing
C) large
D) no output, syntax error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
34
Given the following code, what is the final value of i?
Int i,j;
Fori=0;i<4;i++)
{
Forj=0;j<3;j++)
{
Ifi==2)
Break;
}
}
A) 3
B) 4
C) 5
D) 0
Int i,j;
Fori=0;i<4;i++)
{
Forj=0;j<3;j++)
{
Ifi==2)
Break;
}
}
A) 3
B) 4
C) 5
D) 0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
35
If you want a loop to quit iterating if x < 10 and y > 3, what would be the proper loop condition test?
A) x < 10 && y > 3)
B) x >10 || y < 3)
C) x >=10 && y <=3)
D) x >=10 || y <=3)
A) x < 10 && y > 3)
B) x >10 || y < 3)
C) x >=10 && y <=3)
D) x >=10 || y <=3)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
36
How many times is "Hi" printed to the screen
Forint i=0;i<14;i++);
Cout <<"Hi\n";
A) 13
B) 15
C) 14
D) 1
Forint i=0;i<14;i++);
Cout <<"Hi\n";
A) 13
B) 15
C) 14
D) 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
37
Which of the following is not a good reason for choosing a certain loop control?
A) What the loop does
B) The minimum number of iterations of the loop
C) The condition for ending the loop
D) If the loop is in a function
A) What the loop does
B) The minimum number of iterations of the loop
C) The condition for ending the loop
D) If the loop is in a function
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
38
What is the value of x after the following code executes?
Int x=10;
If ++x >10)
{
X =13;
}
A) 10
B) 9
C) 13
D) 11
Int x=10;
If ++x >10)
{
X =13;
}
A) 10
B) 9
C) 13
D) 11
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
39
if x is 0, what is the value of !x ==0)?
A) false
B) true
C) unable to determine
D) A
A) false
B) true
C) unable to determine
D) A
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
40
Which of the following are equivalent to !x<15 && y>=3))?
A) x>15 && y<=3)
B) x>=15 && y < 3)
C) x>=15 || y < 3)
D) x>15 || y < 3)
E) C and D
A) x>15 && y<=3)
B) x>=15 && y < 3)
C) x>=15 || y < 3)
D) x>15 || y < 3)
E) C and D
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
41
What is NOT an advantage of an enum class over a standard enum?
A) Doesn't map to an integer
B) Values are not global in scope
C) Occupies less memory
A) Doesn't map to an integer
B) Values are not global in scope
C) Occupies less memory
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
42
If you need to write a do-while loop that will ask the user to enter a number between 2 and 5 inclusive, and will keep asking until the user enters a correct number, what is the loop condition?
A) 2<=num<=5)
B) 2<5C) 2 <= number && number <= 5)
D) 2 < number || number > 5)
E) 2 > number && number > 5)
A) 2<=num<=5)
B) 2<5
D) 2 < number || number > 5)
E) 2 > number && number > 5)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
43
Which of the following are valid case statements in a switch?
A) case 1:
B) case x<4:
C) case 'ab':
D) case 1.5:
A) case 1:
B) case x<4:
C) case 'ab':
D) case 1.5:
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
44
What is wrong with the following for loop?
Forint i=0;i<10;i--)
{
Cout << "Hello\n";
}
A) can not use a for-loop for this
B) i is not initialized
C) infinite loop
D) off-by-one error
Forint i=0;i<10;i--)
{
Cout << "Hello\n";
}
A) can not use a for-loop for this
B) i is not initialized
C) infinite loop
D) off-by-one error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
45
Which loop structure always executes at least once?
A) do-while
B) for
C) while
D) sentinel
A) do-while
B) for
C) while
D) sentinel
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck