Posts

Showing posts from June, 2023

while loop in C#

  1. while loop: The test condition is given in the beginning of the loop and all statements are executed till the given Boolean condition satisfies. when the condition becomes false, the control will be out from the while loop.   If the number of iterations is not fixed, it is recommended to use while loop than for loop.   Syntax: while (boolean condition) {    loop statements } Examples: 1.    Basic condition. 2.    Nested while loop.

For loop

  Condition Looping: à Loops are used to execute one or more statements multiple times until a specified condition is fulfilled. à Loops can be nested in C#.   C# provides 4 loops that allow you to execute a block of code repeatedly until a certain condition is met; they are:   1.    for Loop. 2.    while loop. 3.    do while Loop. 4.    foreach Loop.   Each and every loop requires the following 3 things in common.   Initialization : that sets a starting point of the loop.   Condition : that sets an ending point of the loop.   Iteration : that provides each level, the iterator defines the incremental or decremental of the loop variable. 1. for loop: The for keyword indicates a loop in C#.   The for loop executes a block of statements repeatedly until the specified condition returns false.     The ...