Showing posts with label Loop in Programming. Show all posts
Showing posts with label Loop in Programming. Show all posts

What are the entry controlled and exit controlled loops?

Loops in computer programs refers to a block of code that is executed over and over based on meeting some criteria or condition. However a loop can be broke or exited from inside the loop also. The block of code in a loop keeps on executing again and again unless it meets a certain condition or being exited explicitly from inside the loop. Thus, if not well-conditioned a loop might keep on running causing the program to fail ultimately.

Depending on the position of the control statement in the loop, loops can be of two types
  1. Entry Controlled 
  2. Exit Controlled
Beside this, loops can be categorized in to two other categories called counter controlled loops and sentinel controlled loops based on the nature of the control variables and the kind of value assigned to them. You can lean more about counter and sentinel controlled loops here and learn more about the differences between counter and sentinel controlled loops here.

What is loop


A loop is a particular area of a program where some executable statements are written which gets execution by testing one or more conditions. So, in looping, a sequence of statements is executed until some conditions for termination are satisfied.

A program loop therefore consists of two segments; the body of the loop and the control statement.