What are Loops?
- Looping is a process in which a sequence or path is repeated again and again until given condition becomes false.
- In looping a program executes the sequence of statements many times until the given condition becomes false.
- A loop consists of two parts, a body of a loop and a control statement.
Types of Loops
- Depending upon the position of a control statement in a program, a loop is classified into two types:
- Entry controlled loop
- Exit controlled loop
- In an entry controlled loop, a condition is checked before executing the body of a loop. It is also called as a pre-checking loop.
Exit controlled loop
- In an exit controlled loop, a condition is checked after executing the body of a loop. It is also called as a post-checking loop.