Program Control Structures: Repetition Control Structures Flashcards
are used when a program needs to repeatedly process one or more instructions until some condition is met, at which time the loop ends.
Repetition structures, or loops,
The process of performing the same task over and over again is called iteration, and C++ provides built
Iteration
C++ provides three different forms of repetition statements:
While Structure
For Structure
Do-While Structure
If the test occurs at the beginning of the loop, the type of loop is called
pre test loop or entrance
controlled loop.
If the test occurs at the end of the loop, the type of loop is called
post test loop or exit controlled loop.
is used for repeating a statement
or series of statements as long as a given conditional expression evaluates to true
for statement
what is an example of pre-test loop
for and while statement
what is an example of a post-test loop
do-while statement
The condition may be any expression, and true is any non-zero value.
True
In do-while, statements in the loop are executed first at least once
True
A __________ statement causes execution to skip to the next iteration of the loop
continue statement
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.
True
In for loop, initialization happens first and only once
True
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.
True
When does the code block following while(x<100) execute?
When x is less than 100