Thursday, 31 March 2016

Program to print 1 23 456 78910 pattern using for loop in C++ Language.

Wap to print following pattern using for loop in C++ Language.
 

// 1
// 2 3
// 4 5 6
// 7 8 9 10
// 11 12 13 14


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

void main()
{
clrscr();

int i,j,n=1;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
cout<<n;
n++;
}
cout<<"\n";
}getch();
}


Output:-

No comments:

Post a Comment