Deck 4: Control Statements, Part 2
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/28
العب
ملء الشاشة (f)
Deck 4: Control Statements, Part 2
1
Which of the following is a parameterized stream manipulator used to format output?
A) setw
B) right
C) left
D) fixed
A) setw
B) right
C) left
D) fixed
A
2
Which of the following is a poor programming practice?
A) Indenting the statements in the body of each control structure.
B) Using floating-point values for counters in counter-controlled repetition.
C) Nesting multiple repetition structures.
D) Placing vertical spacing above and below control structures.
A) Indenting the statements in the body of each control structure.
B) Using floating-point values for counters in counter-controlled repetition.
C) Nesting multiple repetition structures.
D) Placing vertical spacing above and below control structures.
B
3
Which of the following data types can be used to represent integers?
A) char
B) long
C) short
D) All of the above.
A) char
B) long
C) short
D) All of the above.
D
4
In a switch structure:
A) A break is required after each case.
B) Multiple actions in a case do not need to be enclosed in braces.
C) A default case is required.
D) A break is required after the default case.
A) A break is required after each case.
B) Multiple actions in a case do not need to be enclosed in braces.
C) A default case is required.
D) A break is required after the default case.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which of the following for headers is not valid?
A) for int i = 0; i < 10; i++ )
B) int i = 0; for ; i < 10; i++ )
C) for int i = 0; int j = 5; ; i++ )
D) All of the above.
A) for int i = 0; i < 10; i++ )
B) int i = 0; for ; i < 10; i++ )
C) for int i = 0; int j = 5; ; i++ )
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following statements about the for statement is false?
A) The three expressions in the for statement are optional.
B) The initialization and increment expressions can be comma-separated lists.
C) You must declare the control variable before the for statement.
D) A for statement can always be used to replace a while statement, and vice versa.
A) The three expressions in the for statement are optional.
B) The initialization and increment expressions can be comma-separated lists.
C) You must declare the control variable before the for statement.
D) A for statement can always be used to replace a while statement, and vice versa.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
7
An operator that associates from right to left is:
A) !=
B) ,
C) )
D) ?:
A) !=
B) ,
C) )
D) ?:
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
8
If a variable is declared in the initialization expression of a for statement, then:
A) It is automatically reinitialized to zero once the loop is finished.
B) The scope of the variable is restricted to that for loop.
C) It retains its final value after the loop is finished.
D) It can not be used in any structures that are nested in that for structure.
A) It is automatically reinitialized to zero once the loop is finished.
B) The scope of the variable is restricted to that for loop.
C) It retains its final value after the loop is finished.
D) It can not be used in any structures that are nested in that for structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
9
What will the following program segment do?
Int counter = 1;
Do
{
Cout << counter << " ";
} while ++counter <= 10 );
A) Print the numbers 1 through 11.
B) Print the numbers 1 through 10.
C) Print the numbers 1 through 9.
D) Cause a syntax error.
Int counter = 1;
Do
{
Cout << counter << " ";
} while ++counter <= 10 );
A) Print the numbers 1 through 11.
B) Print the numbers 1 through 10.
C) Print the numbers 1 through 9.
D) Cause a syntax error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
10
Float and double variables should be used:
A) To perform monetary calculations.
B) As counters.
C) To store true/false values.
D) As approximate representations of decimal numbers.
A) To perform monetary calculations.
B) As counters.
C) To store true/false values.
D) As approximate representations of decimal numbers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
11
A switch statement should be used:
A) As a single-selection structure.
B) As a double-selection structure.
C) As a multiple-selection structure.
D) To replace all if…else statements.
A) As a single-selection structure.
B) As a double-selection structure.
C) As a multiple-selection structure.
D) To replace all if…else statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
12
The OR ||) operator:
A) Has higher precedence than the AND &&) operator.
B) Stops evaluation upon finding one condition to be true.
C) Associates from right to left.
D) Is a ternary operator.
A) Has higher precedence than the AND &&) operator.
B) Stops evaluation upon finding one condition to be true.
C) Associates from right to left.
D) Is a ternary operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following does counter-controlled repetition require?
A) An initial value.
B) A condition that tests for the final value.
C) An increment or decrement by which the control variable is modified each time through the loop.
D) All of the above.
A) An initial value.
B) A condition that tests for the final value.
C) An increment or decrement by which the control variable is modified each time through the loop.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
14
Consider the execution of the following for loop
For int x = 1; x < 5; increment )
Cout << x + 1 << endl;
If the last value printed is 5, which of the following might have been used for increment?
A) x++
B) x += 1
C) ++x
D) Any of the above.
For int x = 1; x < 5; increment )
Cout << x + 1 << endl;
If the last value printed is 5, which of the following might have been used for increment?
A) x++
B) x += 1
C) ++x
D) Any of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following is false?
A) The effects of break and continue statements can be achieved by structured programming techniques.
B) break and continue statements can make a program perform faster than with the corresponding structured techniques.
C) Many programmers feel that break and continue violate structured programming.
D) You should always try to write the fastest, smallest code possible before attempting to make it simple and correct.
A) The effects of break and continue statements can be achieved by structured programming techniques.
B) break and continue statements can make a program perform faster than with the corresponding structured techniques.
C) Many programmers feel that break and continue violate structured programming.
D) You should always try to write the fastest, smallest code possible before attempting to make it simple and correct.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
16
In C++, the condition 4 > y > 1 ):
A) Evaluates correctly and could be replaced by 4 > y && y > 1 ).
B) Does not evaluate correctly and should be replaced by 4 > y && y > 1 ).
C) Evaluates correctly and could not be replaced by 4 > y && y > 1 ).
D) Does not evaluate correctly and should not be replaced by 4 > y && y > 1 ).
A) Evaluates correctly and could be replaced by 4 > y && y > 1 ).
B) Does not evaluate correctly and should be replaced by 4 > y && y > 1 ).
C) Evaluates correctly and could not be replaced by 4 > y && y > 1 ).
D) Does not evaluate correctly and should not be replaced by 4 > y && y > 1 ).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
17
Switch can be used to test:
A) int constants.
B) float constants.
C) string constants.
D) all types of constants.
A) int constants.
B) float constants.
C) string constants.
D) all types of constants.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following is correct when labeling cases in a switch structure?
A) case1
B) Case1
C) case 1
D) Case 1
A) case1
B) Case1
C) case 1
D) Case 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which of the following is false?
A) break and continue statements alter the flow of control.
B) continue statements skip the remaining statements in the current iteration of the body of the loop in which they're embedded.
C) break statements exit from the loop in which they're embedded.
D) continue and break statements may be embedded only within repetition statements.
A) break and continue statements alter the flow of control.
B) continue statements skip the remaining statements in the current iteration of the body of the loop in which they're embedded.
C) break statements exit from the loop in which they're embedded.
D) continue and break statements may be embedded only within repetition statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
20
If a do…while structure is used:
A) An infinite loop cannot take place.
B) Counter-controlled repetition is not possible.
C) The body of the loop will execute at least once.
D) An off-by-one error cannot occur.
A) An infinite loop cannot take place.
B) Counter-controlled repetition is not possible.
C) The body of the loop will execute at least once.
D) An off-by-one error cannot occur.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following is not one of the C++ control structures?
A) if
B) switch
C) select
D) do…while
A) if
B) switch
C) select
D) do…while
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
22
An example of a unary operator is:
A) The < relational operator.
B) The = assignment operator.
C) The % arithmetic operator.
D) The ! logical operator.
A) The < relational operator.
B) The = assignment operator.
C) The % arithmetic operator.
D) The ! logical operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
23
Of the following, which is not a logic error?
A) Not placing curly braces around the body of an if that contains two statements.
B) Using == to assign a value to a variable.
C) Failing to initialize counter and total variables before the body of a loop.
D) Using commas instead of the two required semicolons in a for header.
A) Not placing curly braces around the body of an if that contains two statements.
B) Using == to assign a value to a variable.
C) Failing to initialize counter and total variables before the body of a loop.
D) Using commas instead of the two required semicolons in a for header.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
24
The ____________, __________ and ____________ are the only three forms of control necessary.
A) switch, if, else.
B) sequence, selection, repetition.
C) break, continue, if…else.
D) for, while, do…while.
A) switch, if, else.
B) sequence, selection, repetition.
C) break, continue, if…else.
D) for, while, do…while.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
25
Consider the following code, assuming that x is an int with an initial value of 12
If x = 6 )
Cout << x;
What is the output?
A) 6
B) 12
C) Nothing.
D) A syntax error is produced.
If x = 6 )
Cout << x;
What is the output?
A) 6
B) 12
C) Nothing.
D) A syntax error is produced.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
26
Which of the following is not one the rules for forming structured programs?
A) Begin with the "simplest activity diagram."
B) Any transition arrow can be reversed.
C) Any action state can be replaced by two action states in sequence.
D) Any action state can be replaced by any control statement.
A) Begin with the "simplest activity diagram."
B) Any transition arrow can be reversed.
C) Any action state can be replaced by two action states in sequence.
D) Any action state can be replaced by any control statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
27
Variables are also known as:
A) lvalues, but can be used as rvalues.
B) lvalues, and cannot be used as rvalues.
C) rvalues, and cannot be used as lvalues.
D) Constant variables.
A) lvalues, but can be used as rvalues.
B) lvalues, and cannot be used as rvalues.
C) rvalues, and cannot be used as lvalues.
D) Constant variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
28
The expression if num != 65 ) cannot be replaced by:
A) if num > 65 || num < 65 )
B) if ! num == 65 ) )
C) if num - 65 )
D) if ! num - 65 ) )
A) if num > 65 || num < 65 )
B) if ! num == 65 ) )
C) if num - 65 )
D) if ! num - 65 ) )
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck