Difference Between Entry Control Loop and Exit Control Loop

Difference Between Entry Control and Exit Control Loop in C

The Key Difference Between Entry Control and Exit Control Loop is that in Entry Control Loop the test condition is checked first and if that condition is true then the block of the statement will be executed, While in Exit control loop first executes body of the loop and checks condition at last.

Loops are the technique to repeat statements until a given condition is true. The c programming language has three types of loops –

  1. while loop,
  2. do-while loop
  3. for loop.

These loops controlled either at Entry level or at Exit level hence loops can be controlled these two ways.

Comparison Chart

Entry Control Loop Exit Control Loop
Entry control loop checks condition first and then
body of the loop will be executed.
Exit control loop first executes body of the loop and
checks condition at last.
Body of loop may or may not be executed at all. Body of loop will be executed at least once because condition is checked at last
For, While are example of Entry control loop Do…while is example of Exit control loop.

Entry Control Loop

  • For Loop
for( i=1; i < = 10; i++)
   {
    sum = sum + i ;
   }
  • While Loop
i=1;
   while(i<=10)
        {
         sum = sum + i; 
         i++
        }

Exit Control Loop

  • Do…While Loop
i=1;
do
 {
 sum = sum + i; 
 i ++;
 }
while(i<=10);

LEAVE A REPLY

Please enter your comment!
Please enter your name here