In previous blog we discuss that Conditional Statements are of two type
- Conditional Branching.
- Conditional Loop.
In previous blog i have explained Conditional Branching in details. In this blog i am going to talk about the Conditional loop.
C# supports 4 different loops that allows us to execute a block of code repeatedly until a certain condition is met, those are ;
- for loop
- while loop
- do while loop
- foreach loop
Every loop requires three things in common
- Initialization which sets starting point for the loop.
- Condition which sets ending point for the loop.
- Iteration which take you to the next level of the cycle either in forward direction or in backward direction.
Note:- The minimum number of execution in case of a do while loop is one because in this case after executing for the 1st time it checks the condition to continue the loop execution. Whereas in case of while loop and for for loop the minimum number of execution will be zero because in both case if the given condition is satisfied then only loop start its execution.
No comments:
Post a Comment