Wednesday, 30 March 2016

Program to print following pattern using for loop in c++ language.

// Wap to print following pattern using for loop in c++ language.
      1
      1 2
      1 2 3
      1 2 3 4
      1 2 3 4 5

Coding:-
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

int i,j,n;

cout<<"Enter the value of n";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<j;

}
cout<<"\n";
}getch();
}

Output:-
                       

No comments:

Post a Comment