Table of Contents
show
Iteration is a process of repeating the same set of statements again and again until the specified condition holds true
Three kinds of iteration statements,
- for statement
- while statement
- do-while statement
General classification of Loops are,
- Counter-controlled loops
- Sentinel-controlled loops
Counter controlled loops,
- It is a form of looping in which the number of iterations to be performed is known in advance
- It is so named because they use a control variable, known as loop counter to keep track of a loop iterations
- It starts with some initial value of the loop counter and terminates when the final value of the loop counter is reached.
- Since the counter-controlled loops iterate a fixed number of times, which is known in advance they are also known as definite repetition loop
The ingredients of counter-controlled loops are,
- Initialization of the loop counter
- An expression (condition) determining whether the loop body should be executed or not
- An expression that manipulates the value of the loop counter so that the condition specified becomes false and loop terminates
Views: 0