C++ Do While Loop (Sinhala)



There are number of instances where we need to run some code in a loop at least once whether the condition is false or not. However, it is also possible with the while loop even. You would just copy and paste the code inside and paste it outside once and the problem is solved. But, this becomes such a tedious issue when it comes to huge codes because maintaining them becomes so hard.
That's when do-while loops come in. Do while loops are structured so that when the code is executed the body of the loop is executed first and then the condition will be checked. Therefore, this can solve our problem easily.
We will talk about a practical application of the do while loop and proceed to more advanced programs in the future.



No comments:

Post a Comment