Deck 3: Control Statements, Part 1

ملء الشاشة (f)
exit full mode
سؤال
What is wrong with the following while loop?
While sum <= 1000 )
Sum = sum - 30;

A) The parentheses should be braces.
B) Braces are required around sum = sum - 30;.
C) There should be a semicolon after while sum <= 1000 ).
D) sum = sum - 30 should be sum = sum + 30 or else the loop may never end.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
In indefinite repetition, an input value:

A) Should always be evaluated before being processed.
B) Should always be processed directly after it is entered.
C) Should never be modified.
D) Can be entered, processed, and evaluated in any order.
سؤال
The data type bool:

A) Can take on values true and false.
B) Can take on any expression as a value.
C) Can take on values -1, 0 or 1.
D) Can only be used in a selection statement.
سؤال
Which operation does not take place in the following example?
Int x = 21;
Double y = 6;
Double z = 14;
Y = x / z;
X = 5.5 * y;

A) Implicit conversion.
B) Promotion.
C) Explicit conversion.
D) Truncation.
سؤال
An uninitialized local variable contains:

A) The value last stored in the memory location reserved for that variable.
B) No value.
C) A value of zero.
D) A randomly assigned value.
سؤال
Which of the following is a double-selection statement?

A) if.
B) if…else.
C) do…while.
D) switch.
سؤال
If grade has the value of 60, what will the following code display?
If grade >= 60 )
Cout << "Passed";

A) nothing.
B) 60
C) Passed
D) cout << "Passed";
سؤال
Indefinite repetition is controlled by a:

A) Counter.
B) Sentinel value.
C) Absence of a condition.
D) Non-constant condition.
سؤال
Which of the following encompasses the other three?

A) Sequence structure.
B) Repetition structure.
C) Control structure.
D) Selection structure.
سؤال
Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:

A) A fatal logic error.
B) A counter exception.
C) A syntax error.
D) An off-by-one error.
سؤال
What is the final value of x after performing the following operations?
Int x = 21;
Double y = 6;
Double z = 14;
Y = x / z;
X = 5.5 * y;

A) 8.25
B) 5.5
C) 5
D) 8
سؤال
Which of the following is true of pseudocode?

A) It's executed by the computer.
B) It helps the programmer "think out" a program.
C) It includes declarations and all types of statements.
D) All of the above are false.
سؤال
A block:

A) Must contain exactly three statements.
B) Cannot contain declarations.
C) Is a compound statement.
D) Is represented by placing a semicolon ;) where a statement would normally be.
سؤال
The conditional operator ?:):

A) Is the only ternary operator in C++.
B) Is a unary operator.
C) Associates from left to right.
D) Accepts two operands.
سؤال
Which of the following is a repetition statement?

A) if.
B) if…else.
C) do…while.
D) switch.
سؤال
How many times will the following loop print hello?
I = 1;
While i <= 10 )
Cout << "hello";

A) 0.
B) 9.
C) 10.
D) An infinite number of times.
سؤال
Display correct if answer is equal to 7 and incorrect if answer is not equal to 7?

A) if answer == 7 ) cout << "correct";
Else
Cout << "incorrect";
B) cout << answer == 7 ? "correct" : "incorrect";
C) cout << answer == 7 ? "correct" : "incorrect" );
D) answer == 7 ? cout << "correct" : cout << "incorrect";
سؤال
In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?

A) Initial state.
B) Final state.
C) Action state.
D) Transition.
سؤال
Pseudocode does not include:

A) Declarations.
B) Input/output.
C) Algorithms.
D) Control structures.
سؤال
Specifying the order in which statements are to be executed in a computer program is called:

A) An algorithm.
B) Transfer of control.
C) Program control.
D) Pseudocode.
سؤال
Which of the following operations has the highest precedence?

A) Postincrement.
B) Multiplication.
C) Addition.
D) Assignment.
سؤال
Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?

A) y = 5;
B) y = x++;
C) y = ++x;
D) y = x + 1
سؤال
To handle situations where a loop must reinitialize a variable at the beginning of each iteration, such re-initialization could be performed by:

A) An assignment statement before the loop body.
B) A declaration inside the loop body.
C) An assignment statement after the loop body.
D) A declaration after the loop body.
سؤال
Which of the following will not increment c by 1?

A) c + 1;
B) c++;
C) ++c;
D) c += 1;
سؤال
Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be:

A) x: 5; y: 3
B) x: 3; y: -1
C) x: 3; y: 5
D) x: 1; y: 2
سؤال
Having a loop within a loop is known as:

A) Recursion.
B) Doubling up.
C) Nesting.
D) Stacking.
سؤال
If x initially contains the value 3, which of the following sets x to 7?

A) x ++ 4;
B) x += 4;
C) x =+ 4;
D) x + 4 = x;
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/27
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Control Statements, Part 1
1
What is wrong with the following while loop?
While sum <= 1000 )
Sum = sum - 30;

A) The parentheses should be braces.
B) Braces are required around sum = sum - 30;.
C) There should be a semicolon after while sum <= 1000 ).
D) sum = sum - 30 should be sum = sum + 30 or else the loop may never end.
D
2
In indefinite repetition, an input value:

A) Should always be evaluated before being processed.
B) Should always be processed directly after it is entered.
C) Should never be modified.
D) Can be entered, processed, and evaluated in any order.
A
3
The data type bool:

A) Can take on values true and false.
B) Can take on any expression as a value.
C) Can take on values -1, 0 or 1.
D) Can only be used in a selection statement.
A
4
Which operation does not take place in the following example?
Int x = 21;
Double y = 6;
Double z = 14;
Y = x / z;
X = 5.5 * y;

A) Implicit conversion.
B) Promotion.
C) Explicit conversion.
D) Truncation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
5
An uninitialized local variable contains:

A) The value last stored in the memory location reserved for that variable.
B) No value.
C) A value of zero.
D) A randomly assigned value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following is a double-selection statement?

A) if.
B) if…else.
C) do…while.
D) switch.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
7
If grade has the value of 60, what will the following code display?
If grade >= 60 )
Cout << "Passed";

A) nothing.
B) 60
C) Passed
D) cout << "Passed";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
8
Indefinite repetition is controlled by a:

A) Counter.
B) Sentinel value.
C) Absence of a condition.
D) Non-constant condition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which of the following encompasses the other three?

A) Sequence structure.
B) Repetition structure.
C) Control structure.
D) Selection structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
10
Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:

A) A fatal logic error.
B) A counter exception.
C) A syntax error.
D) An off-by-one error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
11
What is the final value of x after performing the following operations?
Int x = 21;
Double y = 6;
Double z = 14;
Y = x / z;
X = 5.5 * y;

A) 8.25
B) 5.5
C) 5
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following is true of pseudocode?

A) It's executed by the computer.
B) It helps the programmer "think out" a program.
C) It includes declarations and all types of statements.
D) All of the above are false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
13
A block:

A) Must contain exactly three statements.
B) Cannot contain declarations.
C) Is a compound statement.
D) Is represented by placing a semicolon ;) where a statement would normally be.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
14
The conditional operator ?:):

A) Is the only ternary operator in C++.
B) Is a unary operator.
C) Associates from left to right.
D) Accepts two operands.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following is a repetition statement?

A) if.
B) if…else.
C) do…while.
D) switch.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
16
How many times will the following loop print hello?
I = 1;
While i <= 10 )
Cout << "hello";

A) 0.
B) 9.
C) 10.
D) An infinite number of times.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
17
Display correct if answer is equal to 7 and incorrect if answer is not equal to 7?

A) if answer == 7 ) cout << "correct";
Else
Cout << "incorrect";
B) cout << answer == 7 ? "correct" : "incorrect";
C) cout << answer == 7 ? "correct" : "incorrect" );
D) answer == 7 ? cout << "correct" : cout << "incorrect";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
18
In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?

A) Initial state.
B) Final state.
C) Action state.
D) Transition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
19
Pseudocode does not include:

A) Declarations.
B) Input/output.
C) Algorithms.
D) Control structures.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
20
Specifying the order in which statements are to be executed in a computer program is called:

A) An algorithm.
B) Transfer of control.
C) Program control.
D) Pseudocode.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following operations has the highest precedence?

A) Postincrement.
B) Multiplication.
C) Addition.
D) Assignment.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
22
Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?

A) y = 5;
B) y = x++;
C) y = ++x;
D) y = x + 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
23
To handle situations where a loop must reinitialize a variable at the beginning of each iteration, such re-initialization could be performed by:

A) An assignment statement before the loop body.
B) A declaration inside the loop body.
C) An assignment statement after the loop body.
D) A declaration after the loop body.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which of the following will not increment c by 1?

A) c + 1;
B) c++;
C) ++c;
D) c += 1;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
25
Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be:

A) x: 5; y: 3
B) x: 3; y: -1
C) x: 3; y: 5
D) x: 1; y: 2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
26
Having a loop within a loop is known as:

A) Recursion.
B) Doubling up.
C) Nesting.
D) Stacking.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
27
If x initially contains the value 3, which of the following sets x to 7?

A) x ++ 4;
B) x += 4;
C) x =+ 4;
D) x + 4 = x;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.