Repetition Structures Flashcards

1
Q

What is a repetition structure in programming?

A

A statement or set of statements executed repeatedly.

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

Why are repetition structures better than repeating sequences of statements?

A

They simplify the code and reduce redundancy.

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

What is a loop?

A

A structure used to repeat a statement or set of statements.

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

What are the two types of loops in repetition structures?

A

Condition-controlled and count-controlled loops.

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

How does a condition-controlled loop work?

A

Repeats as long as a true/false condition is satisfied.

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

How does a count-controlled loop work?

A

Repeats a specific number of times.

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

What are While and Do-While loops?

A

Loops that repeat as long as a condition is true.

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

What is a Do-Until loop?

A

A loop that repeats until a condition becomes true.

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

What are the two parts of a While loop?

A

A condition tested for true/false and the body of the loop with statements to execute.

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

What is an iteration?

A

Execution of a loop’s body.

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

What makes a While loop a pretest loop?

A

It tests its condition before executing the loop body.

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

What causes an infinite loop?

A

Failing to make the test condition false within the loop.

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

How is a Do-While loop different from a While loop?

A

It performs at least one iteration before testing its condition.

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

What is a count-controlled loop’s counter variable?

A

A variable used to track the number of iterations.

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

What are the three actions for a counter variable in a For loop?

A

Initialize, test against a maximum value, and increment.

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

What happens when the counter exceeds the test value in a count-controlled loop?

A

The loop exits.

17
Q

What is a running total?

A

A sum of numbers accumulated during loop iterations.

18
Q

What is an accumulator?

A

A variable that stores the running total.

19
Q

What is a sentinel in loops?

A

A special value marking the end of a list of values.

20
Q

What is a nested loop?

A

A loop inside another loop.

21
Q

How do inner and outer loops work in nested loops?

A

Inner loops complete all iterations for every single iteration of the outer loop.

22
Q

What is the main feature of a pretest loop?

A

It evaluates the condition before any iteration occurs.

23
Q

What is the primary feature of a posttest loop like Do-While?

A

It ensures at least one iteration before testing the condition.

24
Q

What shape is used to represent a For statement in a flowchart?

A

Hexagon.

25
Q

What must happen within a loop to prevent infinite looping?

A

The loop’s condition must eventually be made false.