1.       Difference Between Entry Controlled Loop and Exit Controlled Loop
2.       Difference Between Break and Continue
3.       Difference Between While and Do…While


1.    Difference Between Entry Controlled Loop and Exit Controlled Loop

Entry Controlled Loop
Exit Controlled Loop
In entry controlled loop condition is checked at the starting of the loop.
In exit controlled loop condition is checked at the top of the loop.
In entry controlled loop if condition is fake at the primary trial the body of the loop never executes.
In exit controlled loop if condition is fake at the primary trial the body of the loop executes a minimum of once.


2.   
Difference Between Break and Continue

Break
Continue
Break statement is employed to transfer control of the program immediately after the loop or switch case statement.
Continue statement is employed to skip some a part of the loop and moves to subsequent iteration.

3.   
Difference Between While and Do…while

While
Do…while
In while loop condition is checked at the start of loop.
In do…while condition is checked at the top of loop.
It is referred to as entry controlled loop.
It is referred to as exit controlled loop.
If condition is fake at the primary trial body of the loop never executes in while loop.
If condition is fake at the primary trial body of the loop executes a minimum of once.
Syntax:
While(condition)
{
Body of loop
}
Syntax:
do
{
Body of loop
}While(condition)
Example:
Int i=8;
While(i>10)
{
Printf(%d\n”,i);
i++;
}
Output :
No Output
Example :
int i=8;
do
{
Printf(“%d\n”,i);
i++;
}while(i>10);
Output :
8

Post a Comment

Please do not enter any spam link in the comment box.

Previous Post Next Post