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