do-while Loop in c++:
Circles come into utilization when we really want to execute a block of proclamations more than once. Like while the do-while circle execution is additionally ended based on a test condition. The principal contrast between a do-while circle and some time circle is in the do-while circle the condition is tried toward the finish of the circle body, i.e do-while circle is exit controlled though the other two circles are section controlled circles.
you also study while-loop in c++ by clicking on the following loop:
Note: In the do-while loop, the loop body will execute at least once irrespective of the test condition.
syntax:
do
{
// loop body
update_expression;
}
while (test_expression);
The different pieces of the do-while circle are:
Test Articulation:
In this articulation, we need to test the condition. On the off chance that the condition assesses to valid, we will execute the body of the circle and go to the update articulation. Any other way, we will exit from the while circle.
Update Articulation:
Subsequent to executing the circle body, this articulation increases/decrements the circle variable by some worth.
Body:
It is the Assortment of explanations i.e, factors and works, and so forth. The condition isn't fulfilled until the condition is executed naturally after an effective cycle. do-while circle, code can be utilized to print straightforward names, execute complex calculations, or carry out useful tasks.
Example : This program will try to print “Hello World” depending on a few conditions.
- C++:
No comments:
Post a Comment