Quantcast
Channel: The Crazy Programmer
Viewing all articles
Browse latest Browse all 761

Difference between while and do while Loop

$
0
0

Here you will get to know about difference between while and do while loop.

Both while and do while loops are used to execute set of statements multiple times. But there are some differences between them in terms of syntax and working that I have discussed below.

Difference between while and do while Loop

while loop syntax

while(condition){
	loop body;
}

do while loop syntax

do{
	loop body;
}while(condition);

while loop do while loop
It is entry controlled loop. That means condition is checked at the start of loop body. It is exit controlled loop. That means condition is checked at the end of loop body.
Loop body is not executed if condition is false. Loop body is executed once even if condition is false.
Generally not used for making menu driven programs. Generally used for making menu driven programs.

The post Difference between while and do while Loop appeared first on The Crazy Programmer.


Viewing all articles
Browse latest Browse all 761

Trending Articles