#include<stdio.h>
int main()
{
int i,j,k,n;
printf("enter the number");
scanf("%d",&n);
int a=1,b=20,c=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf("%d ",a);
a++;
}
for(k=i+1;k<c;k++)
{
printf("%d ",b);
b--;
}
printf("\n");
}
return 0;
}
output:
enter the number4
1 20 19 18 17
2 3 16 15 14
4 5 6 13 12
7 8 9 10 11
int main()
{
int i,j,k,n;
printf("enter the number");
scanf("%d",&n);
int a=1,b=20,c=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf("%d ",a);
a++;
}
for(k=i+1;k<c;k++)
{
printf("%d ",b);
b--;
}
printf("\n");
}
return 0;
}
output:
enter the number4
1 20 19 18 17
2 3 16 15 14
4 5 6 13 12
7 8 9 10 11
No comments:
Post a Comment