print following patterns
1 | |||||||||
1 | 2 | 1 | |||||||
1 | 2 | 3 | 2 | 1 | |||||
1 | 2 | 3 | 4 | 3 | 2 | 1 | |||
1 | 2 | 3 | 4 | 5 | 4 | 3 | 2 | 1 |
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=0;i<=5;i++)
{
for(j=1;j<=5-i;j++)
printf(" ");
for(j=1;j<=i;j++)
printf("%2d",j);
for(j=i-1;j>=1;j--)
printf("%2d",j);
printf("\n");
}
getch();
}
Output:-
0 Comments