What is Nested do while loop in C Programming langauge ?

nested do while loop in c

In this article we will going to discuss last topic of looping which is nested do while loop in which following topics are included,
  • Nested do while loop
  • Syntax of nested do while loop
  • Example of nested do while loop

Nested do while loop:

A nested do while loop(statement) in C is nothing but, When one or more do while loop are declared within block of another do while loop such condition is called nested do while loop(statement) in C.

The first do while loop in nested loop is treated as outer do while loop in another hand other do while loops which are declared within the block of another loop is treated as inner do while loop.

Syntax of nested do while loop:


do
{
     Statement 1;
        do
     {
         Statement 1;
         .
         .
        Statement n;
     }
      while(condition);

    Statement 2;
    Statement 3;
    .
    .
    Statement n;
}
  while(condition);

Example of nested do while loop:

#include<stdio.h>
int main()
{
  int i,j,n=1;
  i=1;
  printf("\n table from 1 to 10--\n);
   do
{    
  j=1;
    do
       {
           printf( " %4d ", n*j);
            J++;
        }while(j<=10);
   printf("\n");
   n++;
   i++;
}while(i<=10);
return 0;
_____________________________________________________________

nested do while loop example in c
_____________________________________________________________

Conclusion:

In this article we have learned about nested do while loop in detail with its example and syntax I hope, after reading this article you have no any doubt remain, but still if you have any doubt then feel free comment below.
Post a Comment (0)
Previous Post Next Post