Skip to content

Instantly share code, notes, and snippets.

@SohanChy
Last active August 29, 2015 14:23
Show Gist options
  • Save SohanChy/a2098447fc7cc40e195b to your computer and use it in GitHub Desktop.
Save SohanChy/a2098447fc7cc40e195b to your computer and use it in GitHub Desktop.
Number Pyramid in C
#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