Deck 4: Performing Loops
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
سؤال
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/51
العب
ملء الشاشة (f)
Deck 4: Performing Loops
1
In the following segment of code,
Number = 1;
While(number
The body of the loop is ____.
A) empty
B) cout
C) cout
D) number
Number = 1;
While(number
The body of the loop is ____.
A) empty
B) cout
C) cout
D) number
C
2
The following loop will execute ____ time(s).
Number = 1;
While(number
A) 1
B) 9
C) 10
D) an infinite number of
Number = 1;
While(number
A) 1
B) 9
C) 10
D) an infinite number of
D
3
What common pitfall can you identify in the following segment of code?
Number = 1;
While(number
A) The programmer failed to initialize the loop control variable.
B) An unwanted semicolon was added.
C) The programmer forgot the curly braces.
D) It assumes C++ is case sensitive.
Number = 1;
While(number
A) The programmer failed to initialize the loop control variable.
B) An unwanted semicolon was added.
C) The programmer forgot the curly braces.
D) It assumes C++ is case sensitive.
C
4
A ____ loop is one that must execute a specific number of times.
A) while
B) do-while
C) definite
D) count-controlled
A) while
B) do-while
C) definite
D) count-controlled
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
5
If the expression in the while statement is true, the ____ executes, and the Boolean expression is tested again.
A) conditional expression
B) iterator
C) loop body
D) inner loop
A) conditional expression
B) iterator
C) loop body
D) inner loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
6
Many programmers recommend that you initialize every variable in your programs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
7
The initialize portion of a for loop ____.
A) is mandatory
B) can appear in any order in the for statement
C) is separated by a comma from the evaluate portion
D) can contain multiple statements
A) is mandatory
B) can appear in any order in the for statement
C) is separated by a comma from the evaluate portion
D) can contain multiple statements
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
8
The initialize portion of a for loop comes after the evaluate portion.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
9
The segment of code shown below displays "Hello!" ____ times:
Int count;
Const int NUM_LOOPS = 5;
Count = 0;
While( count
A) 0
B) 4
C) 5
D) 6
Int count;
Const int NUM_LOOPS = 5;
Count = 0;
While( count
A) 0
B) 4
C) 5
D) 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
10
If a program runs for several seconds and appears to be doing nothing or produces repeated output, you should suspect an infinite loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
11
A loop body can be a single statement or a block of statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
12
If you fail to initialize a loop control variable, C++ will automatically assign a value of 0 to the variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
13
The do-while loop is a(n) ____ loop.
A) pretest
B) posttest
C) nested
D) inner
A) pretest
B) posttest
C) nested
D) inner
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
14
The following loop will execute ____ time(s).
Number = 1;
While(number
A) 1
B) 9
C) 10
D) an infinite number of
Number = 1;
While(number
A) 1
B) 9
C) 10
D) an infinite number of
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
15
In the following segment of code,
Number = 1;
While(number
The body of the loop is ____.
A) empty
B) everything in between the curly brackets
C) cout
D) number
Number = 1;
While(number
The body of the loop is ____.
A) empty
B) everything in between the curly brackets
C) cout
D) number
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
16
What common pitfall can you identify in the following segment of code?
Number = 1;
While(number
A) The programmer failed to initialize the loop control variable.
B) An unwanted semicolon was added.
C) The programmer forgot the curly braces.
D) The programmer failed to alter the loop control variable.
Number = 1;
While(number
A) The programmer failed to initialize the loop control variable.
B) An unwanted semicolon was added.
C) The programmer forgot the curly braces.
D) The programmer failed to alter the loop control variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
17
As a custom, many programmers use the variable names i and ____ as iterators.
A) a
B) e
C) j
D) x
A) a
B) e
C) j
D) x
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
18
It is preferable to initialize loop control variables at the beginning of a program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
19
In C++, a(n) ____ has an unknown value and is of no practical use.
A) garbage value
B) iterator
C) sentinel value
D) loop control variable
A) garbage value
B) iterator
C) sentinel value
D) loop control variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
20
What common pitfall can you identify in the following segment of code?
Int number;
While(number
A) The programmer failed to initialize the loop control variable.
B) An unwanted semicolon was added.
C) The programmer forgot the curly braces.
D) It assumes C++ is case sensitive.
Int number;
While(number
A) The programmer failed to initialize the loop control variable.
B) An unwanted semicolon was added.
C) The programmer forgot the curly braces.
D) It assumes C++ is case sensitive.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
21
Most often the evaluate part of the for statement compares the loop control variable with a ____________________ or limit.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
22
What happens if you fail to initialize a loop control variable?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
23
A priming _________________________ is an input statement that initializes a variable before a loop begins.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
24
The while loop and the for loop are ____ loops.
A) pretest
B) posttest
C) nested
D) inner
A) pretest
B) posttest
C) nested
D) inner
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
25
To create a loop that executes at least one time, you should use a ____ loop.
A) for
B) while
C) do-while
D) pretest
A) for
B) while
C) do-while
D) pretest
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
26
When you write a loop, what actions must be taken with the loop control variable?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
27
A loop that completely contains another is a(n) ____ loop.
A) protecting
B) parent
C) covering
D) outer
A) protecting
B) parent
C) covering
D) outer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
28
The body of a do-while loop executes ____.
A) zero or more times
B) at least one time
C) at most one time
D) any number of times
A) zero or more times
B) at least one time
C) at most one time
D) any number of times
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
29
A(n) ____________________ loop is one in which the loop control variable is tested after the loop body executes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
30
In what situations would you typically use a loop?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
31
What types of variables should be initialized?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
32
What kind of C++ expression can be placed inside the parentheses in the while statement?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
33
When you place another loop within a loop, the loops are ____ loops.
A) inner
B) nested
C) inside
D) outer
A) inner
B) nested
C) inside
D) outer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
34
A loop that falls entirely within the body of another is a(n) ____ loop.
A) inner
B) child
C) restricted
D) connected
A) inner
B) child
C) restricted
D) connected
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
35
What is a priming input statement?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
36
Totals are ____________________ by processing individual records one at a time in a loop and adding numeric data to a total.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
37
What types of mistakes are easy to make when working with loops?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
38
When should the loop control variable be initialized?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
39
In most C++ compilers you can stop an infinite loop from executing by pressing the Ctrl + ____________________ or Ctrl + Break keys.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
40
The most difficult aspect of working with ____ loops is keeping track of the separate loop control variables that direct the program's execution.
A) nested
B) count-controlled
C) outer
D) definite
A) nested
B) count-controlled
C) outer
D) definite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
41
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
42
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
43
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
44
Write a program that projects sales goals for a salesperson for the next several years.The user should be prompted for a first year's merchandise sales amount and a number of years to project the goals. For the first year, the salesperson's goal is the current sales amount. After that, sales are projected to grow at a rate of 8 percent per year. You should use a do-while loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
45
Write a while loop equivalent to the following for loop:
int count;
for(count = 1; count
int count;
for(count = 1; count
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
46
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
47
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
48
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
49
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
50
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
51
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck