1 2 3 4 |
1 212 32123 4321234 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include <stdio.h> #include <conio.h> void main(){ int i,j,k,l,m; clrscr(); for (i=1;i<=4;i++){ // loop to print space for (j=1;j<=(4-i);j++){ printf(" "); } for (k=i;k>=1;k--){ // loop to print decreasing number printf("%d",k); } for(l=2;l<=i;l++){ //loop to print increasing numbers printf("%d",l); } for (m=1;m<=i;m++){ // loop to print space at last printf(" "); } printf("\n"); } getch(); } |