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