Deck 5: Control Structures II Repetition

ملء الشاشة (f)
exit full mode
سؤال
The control statements in the for loop include the initial statement, loop condition, and update statement.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The number of iterations of a counter-controlled loop is known in advance.
سؤال
What is the output of the following C++ code? <strong>What is the output of the following C++ code?  </strong> A) 0 B) 6 C) 8 D) 10 <div style=padding-top: 35px>

A) 0
B) 6
C) 8
D) 10
سؤال
Assume that all variables are properly declared. The following for loop executes 20 times.
Assume that all variables are properly declared. The following for loop executes 20 times.  <div style=padding-top: 35px>
سؤال
The statement in the body of a while loop acts as a decision maker.
سؤال
Which of the following statements generates a random number between 0 and 50?

A) srand(time(0));
Num = rand() % 50;
B) srand(time(10));
Num = rand()/50;
C) srand(time(0));
Num = rand()50;
D) srand(time(10));
Num = rand() % 50;
سؤال
In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.
سؤال
In a counter-controlled while loop, the loop control variable must be initialized before the loop.
سؤال
What is the next Fibonacci number in the following sequence? 1, 1, 2, 3, 5, 8, 13, 21, ...

A) 34
B) 43
C) 56
D) 273
سؤال
The control variable in a flag-controlled while loop is a bool variable.
سؤال
Consider the following code. (Assume that all variables are properly declared.) This code is an example of a(n) ____ while loop.
<strong>Consider the following code. (Assume that all variables are properly declared.) This code is an example of a(n) ____ while loop.  </strong> A) sentinel-controlled B) flag-controlled C) EOF-controlled D) counter-controlled <div style=padding-top: 35px>

A) sentinel-controlled
B) flag-controlled
C) EOF-controlled
D) counter-controlled
سؤال
The following while loop terminates when j > 20.
The following while loop terminates when j > 20.  <div style=padding-top: 35px>
سؤال
Consider the following code. This code is an example of a(n) ____ while loop.
<strong>Consider the following code. This code is an example of a(n) ____ while loop.  </strong> A) flag-controlled B) counter-controlled C) EOF-controlled D) sentinel-controlled <div style=padding-top: 35px>

A) flag-controlled
B) counter-controlled
C) EOF-controlled
D) sentinel-controlled
سؤال
A loop that continues to execute endlessly is called a(n) ____ loop.

A) end
B) unhinged
C) infinite
D) definite
سؤال
In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).

A) looping
B) branching
C) selection
D) sequence
سؤال
What is the output of the following C++ code? <strong>What is the output of the following C++ code?  </strong> A) 24 0 B) 24 1 C) 25 0 D) 25 1 <div style=padding-top: 35px>

A) 24 0
B) 24 1
C) 25 0
D) 25 1
سؤال
Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5.
Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5.  <div style=padding-top: 35px>
سؤال
A(n) ____-controlled while loop uses a bool variable to control the loop.

A) counter
B) sentinel
C) flag
D) EOF
سؤال
In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read.
سؤال
Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code? <strong>Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code?  </strong> A) 92 B) 109 C) 110 D) 119 <div style=padding-top: 35px>

A) 92
B) 109
C) 110
D) 119
سؤال
The ____________________ statement is typically used for two purposes:
• To exit early from a loop.
• To skip the remainder of a switch structure.
سؤال
Which of the following loops does not have an entry condition?

A) EOF-controlled while loop
B) sentinel-controlled while loop
C) do...while loop
D) for loop
سؤال
What is the output of the following loop? <strong>What is the output of the following loop?  </strong> A) St B) Sto C) Stop D) This is an infinite loop. <div style=padding-top: 35px>

A) St
B) Sto
C) Stop
D) This is an infinite loop.
سؤال
Which executes first in a do...while loop?

A) the statement
B) loop condition
C) the expression
D) update statement
سؤال
The ____ statement can be used to eliminate the use of certain (flag) variables.

A) while
B) switch
C) break
D) if
سؤال
What executes immediately after a continue statement in a while and do-while loop?

A) loop-continue test
B) update statement
C) loop condition
D) the body of the loop
سؤال
When a continue statement is executed in a ____, the update statement always executes.

A) while loop
B) for loop
C) switch structure
D) do...while loop
سؤال
A loop ____________________ is a set of statements that remains true each time the loop body is executed.
سؤال
To generate a random number, you can use the function rand of the header file ____________________.
سؤال
What is the initial statement in the following for loop? (Assume that all variables are properly declared.) <strong>What is the initial statement in the following for loop? (Assume that all variables are properly declared.)  </strong> A) i = 1; B) i < 20; C) i++; D) cout << Hello World; <div style=padding-top: 35px>

A) i = 1;
B) i < 20;
C) i++;
D) cout << "Hello World";
سؤال
Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code? <strong>Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code?  </strong> A) 24 B) 25 C) 41 D) 42 <div style=padding-top: 35px>

A) 24
B) 25
C) 41
D) 42
سؤال
A semicolon at the end of the for statement (just before the body of the loop) is a(n) ____________________ error.
سؤال
The function eof is a member of the data type ____________________.
سؤال
What is the value of x after the following statements execute? <strong>What is the value of x after the following statements execute?  </strong> A) 5 B) 10 C) 20 D) 40 <div style=padding-top: 35px>

A) 5
B) 10
C) 20
D) 40
سؤال
Which of the following loops is guaranteed to execute at least once?

A) counter-controlled while loop
B) for loop
C) do...while loop
D) sentinel-controlled while loop
سؤال
____ loops are called posttest loops.

A) break
B) for
C) while
D) do...while
سؤال
Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code? <strong>Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code?  </strong> A) 124 B) 125 C) 126 D) 127 <div style=padding-top: 35px>

A) 124
B) 125
C) 126
D) 127
سؤال
Which of the following is a repetition structure in C++?

A) if
B) switch
C) while...do
D) do...while
سؤال
What is the output of the following C++ code? <strong>What is the output of the following C++ code?  </strong> A) 10 B) 10 10 C) 10 11 D) 11 11 <div style=padding-top: 35px>

A) 10
B) 10 10
C) 10 11
D) 11 11
سؤال
In a while and for loop, the loop condition is evaluated before executing the body of the loop. Therefore, while and for loops are called ____________________ loops.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 5: Control Structures II Repetition
1
The control statements in the for loop include the initial statement, loop condition, and update statement.
True
2
The number of iterations of a counter-controlled loop is known in advance.
True
3
What is the output of the following C++ code? <strong>What is the output of the following C++ code?  </strong> A) 0 B) 6 C) 8 D) 10

A) 0
B) 6
C) 8
D) 10
D
4
Assume that all variables are properly declared. The following for loop executes 20 times.
Assume that all variables are properly declared. The following for loop executes 20 times.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
The statement in the body of a while loop acts as a decision maker.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following statements generates a random number between 0 and 50?

A) srand(time(0));
Num = rand() % 50;
B) srand(time(10));
Num = rand()/50;
C) srand(time(0));
Num = rand()50;
D) srand(time(10));
Num = rand() % 50;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
In a counter-controlled while loop, the loop control variable must be initialized before the loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
What is the next Fibonacci number in the following sequence? 1, 1, 2, 3, 5, 8, 13, 21, ...

A) 34
B) 43
C) 56
D) 273
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
The control variable in a flag-controlled while loop is a bool variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
Consider the following code. (Assume that all variables are properly declared.) This code is an example of a(n) ____ while loop.
<strong>Consider the following code. (Assume that all variables are properly declared.) This code is an example of a(n) ____ while loop.  </strong> A) sentinel-controlled B) flag-controlled C) EOF-controlled D) counter-controlled

A) sentinel-controlled
B) flag-controlled
C) EOF-controlled
D) counter-controlled
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
The following while loop terminates when j > 20.
The following while loop terminates when j > 20.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
Consider the following code. This code is an example of a(n) ____ while loop.
<strong>Consider the following code. This code is an example of a(n) ____ while loop.  </strong> A) flag-controlled B) counter-controlled C) EOF-controlled D) sentinel-controlled

A) flag-controlled
B) counter-controlled
C) EOF-controlled
D) sentinel-controlled
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
A loop that continues to execute endlessly is called a(n) ____ loop.

A) end
B) unhinged
C) infinite
D) definite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).

A) looping
B) branching
C) selection
D) sequence
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
What is the output of the following C++ code? <strong>What is the output of the following C++ code?  </strong> A) 24 0 B) 24 1 C) 25 0 D) 25 1

A) 24 0
B) 24 1
C) 25 0
D) 25 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5.
Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
A(n) ____-controlled while loop uses a bool variable to control the loop.

A) counter
B) sentinel
C) flag
D) EOF
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code? <strong>Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code?  </strong> A) 92 B) 109 C) 110 D) 119

A) 92
B) 109
C) 110
D) 119
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
The ____________________ statement is typically used for two purposes:
• To exit early from a loop.
• To skip the remainder of a switch structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which of the following loops does not have an entry condition?

A) EOF-controlled while loop
B) sentinel-controlled while loop
C) do...while loop
D) for loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
What is the output of the following loop? <strong>What is the output of the following loop?  </strong> A) St B) Sto C) Stop D) This is an infinite loop.

A) St
B) Sto
C) Stop
D) This is an infinite loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which executes first in a do...while loop?

A) the statement
B) loop condition
C) the expression
D) update statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
The ____ statement can be used to eliminate the use of certain (flag) variables.

A) while
B) switch
C) break
D) if
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
What executes immediately after a continue statement in a while and do-while loop?

A) loop-continue test
B) update statement
C) loop condition
D) the body of the loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
When a continue statement is executed in a ____, the update statement always executes.

A) while loop
B) for loop
C) switch structure
D) do...while loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
A loop ____________________ is a set of statements that remains true each time the loop body is executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
To generate a random number, you can use the function rand of the header file ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
What is the initial statement in the following for loop? (Assume that all variables are properly declared.) <strong>What is the initial statement in the following for loop? (Assume that all variables are properly declared.)  </strong> A) i = 1; B) i < 20; C) i++; D) cout << Hello World;

A) i = 1;
B) i < 20;
C) i++;
D) cout << "Hello World";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code? <strong>Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code?  </strong> A) 24 B) 25 C) 41 D) 42

A) 24
B) 25
C) 41
D) 42
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
A semicolon at the end of the for statement (just before the body of the loop) is a(n) ____________________ error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
The function eof is a member of the data type ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
What is the value of x after the following statements execute? <strong>What is the value of x after the following statements execute?  </strong> A) 5 B) 10 C) 20 D) 40

A) 5
B) 10
C) 20
D) 40
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
Which of the following loops is guaranteed to execute at least once?

A) counter-controlled while loop
B) for loop
C) do...while loop
D) sentinel-controlled while loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
____ loops are called posttest loops.

A) break
B) for
C) while
D) do...while
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code? <strong>Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code?  </strong> A) 124 B) 125 C) 126 D) 127

A) 124
B) 125
C) 126
D) 127
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
Which of the following is a repetition structure in C++?

A) if
B) switch
C) while...do
D) do...while
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
What is the output of the following C++ code? <strong>What is the output of the following C++ code?  </strong> A) 10 B) 10 10 C) 10 11 D) 11 11

A) 10
B) 10 10
C) 10 11
D) 11 11
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
In a while and for loop, the loop condition is evaluated before executing the body of the loop. Therefore, while and for loops are called ____________________ loops.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.