Write a program to display the pattern:
Output:-
1234554321
1234 4321
123 321
12 21
1 1
Solution:-
#include
#include
void main()
{
int i,j,k,m=0;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(“%d”,j);
}
for(k=1;k<=m;k++)
{
printf(“ “);
}
for(j=i;j>=1;j--)
{
printf(“%d”,j);
}
printf(“\n”);
m=m+2;
}
getch();
}
No comments:
Post a Comment