do while loop in C#
1. do- while loop:
àThe
do while loop is the same as while loop except that it executes the code block
at least once.
àdo
while loop is similar to while loop with the only difference that it checks the
condition after executing the statements or block of code.
i.e. it will execute the loop body one
time for sure because it checks the condition after executing the statements.
àIt
is similar to the while loop but the while loop has the test condition at the
start of the loop and the do while loop has the test condition at the end of
the loop.
So, it executes at least once always.
àWithin a do-while, continue and break statements to control the flow of execution in the loop.
Syntax:
do
{
//block of code
// These statements will be executed if the condition evaluates to true
// always execute once
}
while (condition);
Examples:
1.
do while loop.
2.
do while loop with break and continue.
Comments
Post a Comment