Thu May 31 2018

Numeric Pyramid

C Programming1311 views

File Name: numeric-pyramid.c

#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

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.