Thursday, October 13, 2011

The Concept of nested loop in C++

Nested Loop :-
                        A nested loop means a loop inside a loop doesn't matter which type of loop you are using but if you use a loop inside a loop then that loop will be called nested loop.
For Example..

#include<iostream.h>
#include<conio.h>
void main(void)
{
clrscr();
for(int num=1;num<=10;num++)
             {
              for(int num2=1;num2<=10;num2++)
                            {


                             cout<<"\nALLAH";
                             }

            }
 getch();
}


NOTE:-
              This program will print "Allah"   (10 X 10) 100 times because as you can see for each value of first loop the next loop will execute ten times so in this way "Allah" will be printed 100 times.

No comments:

Post a Comment