Write a program to print the given pattern.
Input Format:
Input consists of a single integer.
Output Format:
Refer sample output. There is a trailing space at the end of each line.
Sample Input:
5
Sample Output:
5 5 5 5 5 4 4 4 4 3 3 3 2 2 1
Code:
#include <stdio.h>
int main()
{
int n,i,j,a,k=1;
scanf("%d",&n);
a=n;
for(i=0;i<n;i++)
{
for(j=n;j>=k;j--)
{
printf("%d ",a);
}
a--;
k++;
printf("\n");
}
return 0;
}
No comments:
Post a Comment