Last active
August 29, 2015 14:23
-
-
Save SohanChy/a2098447fc7cc40e195b to your computer and use it in GitHub Desktop.
Number Pyramid in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int doseries(int inp); | |
int main() | |
{ | |
int input,i,j,n; | |
scanf("%d",&input); | |
n=doseries(input); | |
printf("\n"); | |
for(i=input;i>0;i--) | |
{ | |
for(j=i;j>0;j--) | |
{ | |
if(n<10){printf("0%d ",n--);} | |
else printf("%d ",n--); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} | |
//this series is for calculating the pyramids | |
doseries(int inp) | |
{ | |
int i; | |
for(i=inp-1;i>0;i--) | |
{ | |
inp=inp+i; | |
} | |
return inp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment