The program must accept an integer N as the input. The program must the desired pattern as shown in the Example Input/Output section.
EXAMPLE INPUT/OUTPUT 1:
INPUT:
4
OUTPUT
1 2 3 4
1 2 2 3 4
1 2 3 3 3 4
1 2 3 4 4 4 4
EXAMPLE INPUT/OUTPUT 2:
INPUT:
5
OUTPUT
1 2 3 4 5
1 2 2 3 4 5
1 2 3 3 3 4 5
1 2 3 4 4 4 4 5
1 2 3 4 5 5 5 5 5
CODE:
#include<stdio.h>int main() { int n,i=1; scanf("%d",&n); while(i<=n) { for(int j=1;j<=n;j++) { if(i==j) { for(int k=0;k<i;k++) { printf("%d ",j); } } else printf("%d ",j); } printf("\n"); i++; }}