Deck 5: Looping

ملء الشاشة (f)
exit full mode
سؤال
A for loop is considered a(n)_ loop.

A)infinite
B)pretest
C)sentinel controlled
D)multi test
E)post test
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The ++ operator

A)adds one to the value of its operand.
B)can operate in prefix or postfix mode.
C)is a unary operator.
D)All of the above.
E)Both B and C, but not A.
سؤال
A for statement contains three expressions: initialization, test, and

A)update.
B)increment.
C)repeat.
D)quit.
E)validate.
سؤال
A sentinel is a special value that

A)marks the end of a list of values.
B)must be Boolean.
C)is used for data validation.
D)must be a negative number.
E)is all of the above.
سؤال
To use files in a C++ program you must include the header file.

A)fstream
B)iostream
C)file
D)Both A and B are needed.
E)Both B and C are needed.
سؤال
To a value means to increase it.

A)add up
B)accumulate
C)increment
D)total
E)decrement
سؤال
The statements in the body of a do-while loop are executed

A)only if the test condition is initially true.
B)forever until the user hits the break key.
C)at least once.
D)until the test condition becomes true.
E)until an exit statement is encountered.
سؤال
The while loop is a(n)loop, whereas the do-while loop is a(n)loop.

A)simple, complex
B)finite, infinite
C)post test, pretest
D)pretest, post test
E)infinite, finite
سؤال
In a for statement, the expression is executed only once.

A)validate
B)initialization
C)test
D)update
E)repeat
سؤال
The ideal type of loop to use for repeating a menu is a(n)_ loop.

A)for
B)do-while
C)nested
D)infinite
E)sentinel controlled
سؤال
In order for a C++ program to read data from a file,

A)the program must open the file.
B)the file must already exist.
C)the program must define a file stream object that can "point to" (i.e., reference)the file.
D)All of the above are required..
سؤال
A(n)is a variable that controls the number of times a loop iterates.

A)total
B)accumulator
C)sentinel
D)counter
E)loop control variable
سؤال
A variable that keeps a running total of data values is called a(n)

A)sum.
B)loop control variable.
C)total.
D)accumulator.
E)counter.
سؤال
The ideal type of loop to use if you want a user to enter exactly 20 values is a(n)loop.

A)sentinel controlled
B)do-while
C)infinite
D)nested
E)for
سؤال
For data validation, it is best to use a(n)

A)switch statement.
B)if statement.
C)for loop.
D)nested loop.
E)while loop.
سؤال
The statement causes a loop to terminate early.

A)stop
B)break
C)continue
D)terminate
E)quit
سؤال
The while loop has two important parts: a condition that is tested and a statement or block of statements that is executed

A)as long as the condition is true.
B)until the condition becomes true.
C)at least once.
D)exactly once.
E)Both A and C are true, but B and D are not.
سؤال
The while loop has two important parts: a condition that is tested and a statement or block of statements that is

A)done once if the condition is true.
B)repeated as long as the condition is true.
C)always skipped.
D)repeated until the condition becomes true.
E)always done at least once, then repeated if the condition is true.
سؤال
A(n)is a special value that marks the end of a list of values.

A)counter
B)loop control variable
C)accumulator
D)sentinel
E)total
سؤال
are C++ operators that change their operands by one.
A)++ and --

A)binary and unary
B)+ and -
B)conditional and relational
C)arithmetic and relational
سؤال
The do- while loop is a(n)loop, whereas the while loop is a(n)loop.

A)post test, pretest
B)infinite, finite
C)simple, complex
D)pretest, post test
E)finite, infinite
سؤال
If a while loop has no braces around the body of the loop

A)the loop body contains just one statement.
B)there is no loop body.
C)the loop body ends when the endwhile statement is encountered.
D)the program will not compile.
E)the program will compile, but not run.
سؤال
An initialization expression may be omitted from the for loop if no initialization is required.
سؤال
A(n)is a variable that is regularly incremented or decremented each time a loop iterates.

A)accumulator
B)total
C)sentinel
D)loop control variable
E)counter
سؤال
You may define a(n)in the initialization expression of a for loop.

A)variable
B)constant
C)new data type
D)operator
E)new keyword
سؤال
To decrement a number means to increase its value.
سؤال
The -- operator

A)subtracts one from the value of its operand.
B)must have an lvalue, such as a variable, as its operand.
C)can be used in either prefix or postfix mode.
D)is a unary operator.
E)All of the above are true.
سؤال
A while loop is somewhat limited because the counter can only be incremented or decremented by one each time through the loop.
سؤال
You can nest a for loop inside another for loop, but cannot nest a while loop inside another while loop or a do-while loop inside another do-while loop.
سؤال
When a loop is nested inside another loop, the inner loop goes through all its iterations for each iteration of the outer loop.
سؤال
When a loop is nested inside another loop, the outer loop goes through all its iterations for each iteration of the inner loop.
سؤال
The statements in the body of a do-while loop are executed

A)forever until the user hits the break key.
B)exactly once.
C)until the test condition becomes true.
D)at least once.
E)only if the test condition is initially true.
سؤال
The block of code in the body of a while statement can contain an unlimited number of statements, provided they are enclosed in a set of braces.
سؤال
To use an output file in a C++ program you must

A)make sure the file already exists.
B)create a file stream object that will "point to" (i.e. reference)the file.
C)open the file.
D)do all of the above.
E)do B and C, but not A.
سؤال
To use files in a C++ program you must include the header file.

A)file
B)iostream
C)fstream
D)Both A and B.
E)Both B and C.
سؤال
A while loop is somewhat limited, because the counter can only count up, not down.
سؤال
A while loop may have a semicolon after the test expression and before the body of the loop, but it is not required.
سؤال
If nothing within a while loop ever causes the condition to become false, a(n)may occur.

A)infinite loop
B)null value
C)compiler error
D)unexpected exit
E)system crash
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/38
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 5: Looping
1
A for loop is considered a(n)_ loop.

A)infinite
B)pretest
C)sentinel controlled
D)multi test
E)post test
B
2
The ++ operator

A)adds one to the value of its operand.
B)can operate in prefix or postfix mode.
C)is a unary operator.
D)All of the above.
E)Both B and C, but not A.
D
3
A for statement contains three expressions: initialization, test, and

A)update.
B)increment.
C)repeat.
D)quit.
E)validate.
A
4
A sentinel is a special value that

A)marks the end of a list of values.
B)must be Boolean.
C)is used for data validation.
D)must be a negative number.
E)is all of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
5
To use files in a C++ program you must include the header file.

A)fstream
B)iostream
C)file
D)Both A and B are needed.
E)Both B and C are needed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
6
To a value means to increase it.

A)add up
B)accumulate
C)increment
D)total
E)decrement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
7
The statements in the body of a do-while loop are executed

A)only if the test condition is initially true.
B)forever until the user hits the break key.
C)at least once.
D)until the test condition becomes true.
E)until an exit statement is encountered.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
8
The while loop is a(n)loop, whereas the do-while loop is a(n)loop.

A)simple, complex
B)finite, infinite
C)post test, pretest
D)pretest, post test
E)infinite, finite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
9
In a for statement, the expression is executed only once.

A)validate
B)initialization
C)test
D)update
E)repeat
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
10
The ideal type of loop to use for repeating a menu is a(n)_ loop.

A)for
B)do-while
C)nested
D)infinite
E)sentinel controlled
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
11
In order for a C++ program to read data from a file,

A)the program must open the file.
B)the file must already exist.
C)the program must define a file stream object that can "point to" (i.e., reference)the file.
D)All of the above are required..
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
12
A(n)is a variable that controls the number of times a loop iterates.

A)total
B)accumulator
C)sentinel
D)counter
E)loop control variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
13
A variable that keeps a running total of data values is called a(n)

A)sum.
B)loop control variable.
C)total.
D)accumulator.
E)counter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
14
The ideal type of loop to use if you want a user to enter exactly 20 values is a(n)loop.

A)sentinel controlled
B)do-while
C)infinite
D)nested
E)for
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
15
For data validation, it is best to use a(n)

A)switch statement.
B)if statement.
C)for loop.
D)nested loop.
E)while loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
16
The statement causes a loop to terminate early.

A)stop
B)break
C)continue
D)terminate
E)quit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
17
The while loop has two important parts: a condition that is tested and a statement or block of statements that is executed

A)as long as the condition is true.
B)until the condition becomes true.
C)at least once.
D)exactly once.
E)Both A and C are true, but B and D are not.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
18
The while loop has two important parts: a condition that is tested and a statement or block of statements that is

A)done once if the condition is true.
B)repeated as long as the condition is true.
C)always skipped.
D)repeated until the condition becomes true.
E)always done at least once, then repeated if the condition is true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
19
A(n)is a special value that marks the end of a list of values.

A)counter
B)loop control variable
C)accumulator
D)sentinel
E)total
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
20
are C++ operators that change their operands by one.
A)++ and --

A)binary and unary
B)+ and -
B)conditional and relational
C)arithmetic and relational
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
21
The do- while loop is a(n)loop, whereas the while loop is a(n)loop.

A)post test, pretest
B)infinite, finite
C)simple, complex
D)pretest, post test
E)finite, infinite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
22
If a while loop has no braces around the body of the loop

A)the loop body contains just one statement.
B)there is no loop body.
C)the loop body ends when the endwhile statement is encountered.
D)the program will not compile.
E)the program will compile, but not run.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
23
An initialization expression may be omitted from the for loop if no initialization is required.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
24
A(n)is a variable that is regularly incremented or decremented each time a loop iterates.

A)accumulator
B)total
C)sentinel
D)loop control variable
E)counter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
25
You may define a(n)in the initialization expression of a for loop.

A)variable
B)constant
C)new data type
D)operator
E)new keyword
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
26
To decrement a number means to increase its value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
27
The -- operator

A)subtracts one from the value of its operand.
B)must have an lvalue, such as a variable, as its operand.
C)can be used in either prefix or postfix mode.
D)is a unary operator.
E)All of the above are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
28
A while loop is somewhat limited because the counter can only be incremented or decremented by one each time through the loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
29
You can nest a for loop inside another for loop, but cannot nest a while loop inside another while loop or a do-while loop inside another do-while loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
30
When a loop is nested inside another loop, the inner loop goes through all its iterations for each iteration of the outer loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
31
When a loop is nested inside another loop, the outer loop goes through all its iterations for each iteration of the inner loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
32
The statements in the body of a do-while loop are executed

A)forever until the user hits the break key.
B)exactly once.
C)until the test condition becomes true.
D)at least once.
E)only if the test condition is initially true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
33
The block of code in the body of a while statement can contain an unlimited number of statements, provided they are enclosed in a set of braces.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
34
To use an output file in a C++ program you must

A)make sure the file already exists.
B)create a file stream object that will "point to" (i.e. reference)the file.
C)open the file.
D)do all of the above.
E)do B and C, but not A.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
35
To use files in a C++ program you must include the header file.

A)file
B)iostream
C)fstream
D)Both A and B.
E)Both B and C.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
36
A while loop is somewhat limited, because the counter can only count up, not down.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
37
A while loop may have a semicolon after the test expression and before the body of the loop, but it is not required.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
38
If nothing within a while loop ever causes the condition to become false, a(n)may occur.

A)infinite loop
B)null value
C)compiler error
D)unexpected exit
E)system crash
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 38 في هذه المجموعة.