Loop Statement:-An Introduction

The sequence or selection construct execute a statement or set of statement only one time during the execution of a program while the iterative construct is used to evaluate a statement or set of statement more then one time during the execution of a program. They are also known as repetitive or loop construct.
The loop /Iterative construct executed in the following manner:
i).The execution of loop is start with the help of a variable (counter) which contains the start value from where the counting is to be started. The value of counter variable must be updated with each step/ iteration of the loop.
iii).The loop is controlled on the basis of a condition which usually compares the counter variable with the specified end value. The condition returns a Boolean
value true or false.
iii).If the condition returns true the statements enclosed within the body of loop are executed continuously. If the given condition is false it skips the statements enclosed within the body of loop. It stops the loop and statements after the loop will execute.
Counter=Start Value
Loop
(condition)
{
Statement 1
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
Statement N
Counter Update
}
Every loop consists of two parts:
1].Body:-It contains single or multiple statements which are execute more then one time.
2].Control Statement:-It
contains a condition which controls the execution of a loop. It must return Boolean value true or false. The control statement can be placed either in the beginning/top of the loop body or end/bottom of the loop body.

Comments