Part-8 C# While loop

1.  WHILE LOOP


The while loop is iteration statement into this loop. you can apply a condition  inside while loop check the condition is true statement execute.

while (Condition)
{
//Code to be execute
 }
Syantax :

The While loop condition a boolean expression as a condition it will return true or false.it execute code.if true execute the code.

int i = 0;

while (i < 10)
{
Console.WriteLine("Value of i", +i);

i++;
}


Note: Do not forget to increase the variable used in the condition , otherwise the loop will never end.



2. Nested While Loop: Nested while loop inside while loop.

   int i = 0;

   while (i < 2)

   {
              Console.WriteLine("Value Is", +i );

               int j = 1;

               i++;

          while (j < 2)
           {
             Console.WriteLine("Value of j",+j);
            j++;
           }
      }