Deck 3: More Flow of Control

ملء الشاشة (f)
exit full mode
سؤال
The compiler always pairs an else with _______________
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
A semicolon by itself is a valid C++ statement.
سؤال
All nested if-else statements can be converted into switch statements.
سؤال
A ____________ expression is an expression that can be thought of as being true or false.
سؤال
A _________ loop always executes the loop body at least once,irregardless of the loop condition.
سؤال
Each repetition of a loop body is called ____________.
سؤال
_________ is a type whose values are defined by a list of constants of type int.
سؤال
The break statement causes all loops to exit.
سؤال
Which boolean operation is described by the following table?
<strong>Which boolean operation is described by the following table?  </strong> A)or B)and C)not D)none of the above <div style=padding-top: 35px>

A)or
B)and
C)not
D)none of the above
سؤال
A switch statement variable must be ________
سؤال
A boolean expression may evaluate to more than 2 values
سؤال
The code following the ________ case is executed if none of the other cases are matched in a switch statement.
سؤال
A break statement in a switch stops your program.
سؤال
A function may return a boolean value.
سؤال
In an enumerated data type,different constants may not have the same value.
سؤال
A loop that iterates one too many or one too few times is said to be ________
سؤال
A compound statement that contains variable declarations is called a __________.
سؤال
All switch statements can be converted into nested if-else statements
سؤال
Variables defined inside a set of braces are said to be _______ to that block of code.
سؤال
It is illegal to make function calls inside a switch statement.
سؤال
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.
سؤال
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
سؤال
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
سؤال
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
سؤال
What is the value of the following expression?
True && 4/3 || !6)))

A)true
B)false
C)0
D)illegal syntax
سؤال
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
سؤال
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)
سؤال
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
سؤال
Which of the following symbols has the highest precedence?

A)++
B)||
C)&&
D)-
سؤال
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.
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
Which boolean operation is described by the following table?
<strong>Which boolean operation is described by the following table?  </strong> A)or B)and C)not D)none of the above <div style=padding-top: 35px>

A)or
B)and
C)not
D)none of the above
سؤال
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)
سؤال
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.
سؤال
if x is 0,what is the value of !x ==0)?

A)false
B)true
C)unable to determine
D)A
سؤال
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
سؤال
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:
سؤال
Which loop structure always executes at least once?

A)do-while
B)for
C)while
D)sentinel
سؤال
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
سؤال
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)
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/44
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: More Flow of Control
1
The compiler always pairs an else with _______________
the nearest previous if not already paired with an else.
2
A semicolon by itself is a valid C++ statement.
True
3
All nested if-else statements can be converted into switch statements.
False
4
A ____________ expression is an expression that can be thought of as being true or false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
5
A _________ loop always executes the loop body at least once,irregardless of the loop condition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
6
Each repetition of a loop body is called ____________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
7
_________ is a type whose values are defined by a list of constants of type int.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
8
The break statement causes all loops to exit.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which boolean operation is described by the following table?
<strong>Which boolean operation is described by the following table?  </strong> A)or B)and C)not D)none of the above

A)or
B)and
C)not
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
10
A switch statement variable must be ________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
11
A boolean expression may evaluate to more than 2 values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
12
The code following the ________ case is executed if none of the other cases are matched in a switch statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
13
A break statement in a switch stops your program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
14
A function may return a boolean value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
15
In an enumerated data type,different constants may not have the same value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
16
A loop that iterates one too many or one too few times is said to be ________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
17
A compound statement that contains variable declarations is called a __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
18
All switch statements can be converted into nested if-else statements
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
19
Variables defined inside a set of braces are said to be _______ to that block of code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
20
It is illegal to make function calls inside a switch statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
21
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
22
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
23
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
24
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
25
What is the value of the following expression?
True && 4/3 || !6)))

A)true
B)false
C)0
D)illegal syntax
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
26
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
27
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
28
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following symbols has the highest precedence?

A)++
B)||
C)&&
D)-
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
30
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
31
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
33
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
34
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
35
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
36
Which boolean operation is described by the following table?
<strong>Which boolean operation is described by the following table?  </strong> A)or B)and C)not D)none of the above

A)or
B)and
C)not
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
37
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
38
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
40
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
41
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:
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
42
Which loop structure always executes at least once?

A)do-while
B)for
C)while
D)sentinel
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
43
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
44
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.