C++ Program to print pyramid a Pattern
1
121
12321
1234321
123454321
#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,k,l;
clrscr();
for(i=1;i<=5;i++)
{
for(k=1;k<=5-i;k++)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
cout<<j;
}
for(l=i-1;l>=1;l--)
{
cout<<l;
}
cout<<"\n";
}
getch();
}
121
12321
1234321
123454321
#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,k,l;
clrscr();
for(i=1;i<=5;i++)
{
for(k=1;k<=5-i;k++)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
cout<<j;
}
for(l=i-1;l>=1;l--)
{
cout<<l;
}
cout<<"\n";
}
getch();
}
No comments:
Post a Comment