Numeric Pyramid

C Programming

C Programming Examples

#include<stdio.h>

int main() {
	int i, j, k, l;
	for(i=1; i<=5; i++) {

		/* Print blank space */
		for(j=i; j<=5; j++)
			printf(" ");

		/* construct left side of the pyramid */
		for(k=1; k<=i; k++)
			printf("%d",k);

		/* Construct  right side of the pyramid */
		for(l=i-1; l>=1; l--)
			printf("%d",l);
		printf("\n");
	}
	return 0;
}


          /****** Output ******/
          

         1

       121

     12321

   1234321

 123454321