Nested For loops in C++

Nested Loops commonly used when we deal with 2D Arrays, Sorting and arranging data . The Principle of the nested loops is that when the inner loop complete its all iterations then the control goes to outer loop and when it process (increment or decrement) then the control again shift to the inner loop and this process continue until the completion of both loops.

Source Code  


#include<iostream>
using namespace std;
int main ()
{
 for (int i =6;i<11;i++)
 {
  for (int k =1;k<6;k++)
 {
 
   cout<<"Inner Loop " <<k <<endl;
 }
 cout<<"****** OUTER LOOP VALUE *****"<<i<<endl; 
 }
 
}

Output of the Program

C++ Programming


Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment