DO NOT MISS

Ads

Wednesday 27 July 2016

Nested while loop with C-Programs


Placing while Structure in a while is known as a Nested while.

Syntax:-


while(cond 1)------------------outer while
{
while(cond 2)
------------------inner while
{
statements;
}
}


Note:-

1. First it checks the outer while condition. 

2. It outer while condition.is true it again checks the inner while condition. 

3. If inner while condition is true it executes the true statements of the inner while and goes inner while condition. 

4. This process will be continuous until the specific inner while condition will be false. 
5. If inner while condition will be false it goes to outer while condition. 
6. If that condition is true repeats the same process. 
7. This process will be continuous until the specified outer while condition is false.

Flow Chart:-

* Write a program to print 10 multiplication tables.

#include<stdio.h>
#include<conio.h>

void main()

    {

           int i,j;
           clrscr();
           i=1;

           
while(i<=10)
                {
                     j=1;
                     while(j<=10)
                             {
                             printf("%d*%d=%d\t",i,j,i*j);
                             j++;
                             }
                     i++;
                }

           getch();

   }



Output:-


_____________________________________
>> Back to Exit Entry Control Statements

-------------------------------------------------------------------------------------------------

Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims