Difference between Do While and Do Until is Do While executes the statements in Loop when condition is TRUE and exits from the loop when condition is FALSE.
But Do Until executes the statements in loop when condition is FALSE and exits from the loop when condition TRUE.
Do While :
Do While < Condition>
<Statement>
Inc/Dec of VAR
[ exit do]
Loop
Example :
Dim N as Integer =1
Do While N <=10
Console.Write(N)
N+1=1
Loop
Out Put : 1 2 3 4 -------- 10
Do Until :
Do Until< Condition>
<Statement>
Inc/Dec of VAR
[ exit do]
Loop
Example :
Dim N as Integer =1
Do Until N >10
Console.Write(N)
N+ =1
Loop
Out Put : 1 2 3 4 -------- 10
But Do Until executes the statements in loop when condition is FALSE and exits from the loop when condition TRUE.
Do While :
Do While < Condition>
<Statement>
Inc/Dec of VAR
[ exit do]
Loop
Example :
Dim N as Integer =1
Do While N <=10
Console.Write(N)
N+1=1
Loop
Out Put : 1 2 3 4 -------- 10
Do Until :
Do Until< Condition>
<Statement>
Inc/Dec of VAR
[ exit do]
Loop
Example :
Dim N as Integer =1
Do Until N >10
Console.Write(N)
N+ =1
Loop
Out Put : 1 2 3 4 -------- 10
No comments:
Post a Comment