5.4.Nested Loop

Example 1:
#include<iostream.h>
#include<conio.h>
void main()
{
        for(int i=2;i<10;i++)
        {
                for(int j=1;j<=10;j++)
                {
             	        cout<<i<<" * "<<j<<" = "<<i*j<<endl;
                }
                cout<<endl;
        }
        getch();
}

Example 2:

#include<iostream.h>
#include<conio.h>
void main()
{
        int n;
        cout<<"Enter N: ";        cin>>n;
        for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=n;j++)
                {
             	        cout<<"* ";
                }
                cout<<endl;
        }
        getch();
}

Example 3:

#include<iostream.h>
#include<conio.h>
void main()
{
        int n;
        cout<<"Enter N: ";        cin>>n;
        for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=n;j++)
                {
             	        cout<<i<<" ";
                }
                cout<<endl;
        }
        getch();
}

Example 4:

#include<iostream.h>
#include<conio.h>
void main()
{
        int n;
        cout<<"Enter N: ";        cin>>n;
        for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=n;j++)
                {
             	        cout<<j<<" ";
                }
                cout<<endl;
        }
        getch();
}
Suggest Edit