In this blog,I will concentrate on the do-while loop.
The difference between "While" and "do-while" loops are as below:
1. In while loop,the condition comes before the body of the loop while in do-while loop,it comes below the body of the loop.
2. In while loop,semi-colon comes after the condition while in do-while loop,semi-colon does not comes after the condition.
3.In while loop,the loop body is not executed at least once while in do-while loop,the loop body is executed at least once.
Now below is a simple example of do-while loop.
The difference between "While" and "do-while" loops are as below:
1. In while loop,the condition comes before the body of the loop while in do-while loop,it comes below the body of the loop.
2. In while loop,semi-colon comes after the condition while in do-while loop,semi-colon does not comes after the condition.
3.In while loop,the loop body is not executed at least once while in do-while loop,the loop body is executed at least once.
Now below is a simple example of do-while loop.
No comments:
Post a Comment