Module 6 Flashcards

1
Q

for loop is pre-test loop

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Each pass through a loop is called a/an ________

A

iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In counter-controlled repetition, it requires the following except _________

  • the name of a control variable
  • the loop-continuation condition that tests for the initial value of the control variable to determine when to exit
  • the control variable to be incremented (or decremented) each time through the loop
  • the initial value of the control variable
A

the loop-continuation condition that tests for the initial value of the control variable to determine when to exit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is correct syntax of for loop?

A

for(initialization; condition; increment/decrement)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The loop iterates while the condition is true.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Values that are used to end loops are referred to as _____ values.

A

Sentinel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The while loop evaluates the test expression inside the parenthesis {} if it is true.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A continue statement causes execution to skip to ______

A

the next iteration of the loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following loop constructs perform the statement at least once?

A

do-while

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which looping process is best used when the number of iterations is known?

A

for

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The statement i++; is equivalent to _________

A

i = i + 1;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

When using do-while loop is that we need to use __________ statement inside while loop so that the loop variable gets changed on each iteration, and at some point condition returns false.

A

update statement/increment or decrement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block?

A

braces { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If the test occurs at the beginning of the loop, the type of loop is called a post-test loop or entrance-controlled loop.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Can a for loop contain another for loop?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

A while loop that never stops is said to be the infinite while loop, when we give the condition in such a way so that it never returns ___.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which of the following is an entry-controlled loop?

  • for only
  • do-while only
  • for and while
A

for and while

19
Q

When the condition becomes true, program control passes to the line immediately following the loop.

20
Q

What’s wrong? while( (i < 10) && (i > 24))

A

the test condition is always false

21
Q

What is the way to suddenly come out of or quit any loop in C++ language?

A

break; statement

22
Q

Given that the increment/decrement operator is ++/– and the first testing is true in a loop, the formula to compute for the number of loops when using the relational operator <= is |TV – IV| + 1

23
Q

goto statement allows making an absolute jump to another point in the program.

24
Q

When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.

25
Condition in for loop is evaluated on each loop iteration, if the condition is false then the statements inside the for loop body gets executed.
False
26
If the test expression is false, the loop terminates (ends).
True
27
Choose correct C++ while loop syntax.
while(condition) { //statements }
28
If the test expression is true, statements inside the body of while loop are executed. Then, the test expression is evaluated again.
False
29
Which of the following is most suitable for a menu-driven program?
do-while
30
continue statement is used to come out of the loop instantly
False
31
Do-while is a pre-test loop
False
32
How many times is a do while loop guaranteed to loop?
1
33
After every execution of for loop’s body, the increment/decrement part of for loop executes that updates the loop counter.
True
34
The statement for (; ;) ______
will loop forever
35
In a group of nested loops, which loop is executed the most number of times?
the innermost loop
36
A loop inside another loop is called a nested loop.
True
37
Which looping process checks the test condition at the end of the loop?
do-while
38
A do-while loop that never stops is said to be the infinite while loop, when we give the condition in such a way so that it never returns ___,
True
39
The destination point is identified by a label, which is then used as an argument for the goto instruction.
True
40
What is the final value of x when the code int x=0; while(x<10) {x++;} is run?
10
41
Which is not a loop structure of C++?
repeat-until
42
What is the effect of writing a break statement inside a loop?
It cancels remaining iterations
43
Which looping process checks the test condition at the beginning of the loop?
for and while
44
Which loop is correct? - do {//code}while (condition) - do {//code}while (condition); - do {//code}while (condition):
do {//code}while (condition);