Thursday, November 19, 2009

Different Between while and do while

14. Different Between while and do while

Execution start from top to bottom
While:

First while loop check condition if true then only execute inside loop otherwise come out from that particular loop.

Do While:

do while do not check condition true or not first time execute one time after that it will check condition if true means execute up to false come, if false fist time come out from that particular loop.

15. Example programs While and do while Loop condition checking
< script type = " text / javascript " >
var i=0;
while (i<0) { document.write("first check condition but condition is false"); } < / script >

16 . Do while condition checking
< script type = " text / javascript " >
var i=0;
do
{
document.write("condition is false but executing one time");

}
while ( i < 0); < / script >

No comments:

Post a Comment