☞
C program to print following pattern.
1
2 3
4 5 6
4 5 6
2 3
1
#include<stdio.h>
int main(){
int i,j,n,k=1;
scanf("%d",&n);
for(i=1;i<=n;i++){
for(j=1;j<=i;j++)
printf("%d\t",k++);
printf("\n");
}
for(i=n;i>=1;i--){
k=i*(i-1)/2;
for(j=1;j<=i;j++)
printf("%d\t",++k);
printf("\n");
}
return 0;
}
Sample Input
3
Sample Output
1
2 3
4 5 6
4 5 6
2 3
1
For mini projects click here
CSE Materials click here
1
2 3
4 5 6
4 5 6
2 3
1
#include<stdio.h>
int main(){
int i,j,n,k=1;
scanf("%d",&n);
for(i=1;i<=n;i++){
for(j=1;j<=i;j++)
printf("%d\t",k++);
printf("\n");
}
for(i=n;i>=1;i--){
k=i*(i-1)/2;
for(j=1;j<=i;j++)
printf("%d\t",++k);
printf("\n");
}
return 0;
}
Sample Input
3
Sample Output
1
2 3
4 5 6
4 5 6
2 3
1
For mini projects click here
CSE Materials click here