Hello fellow programmers,
I'm a beginner in learning C and stuck at a problem.
As the title suggests, I want to print a Reverse pyramid. Now it was easy if I wanted to print asterisk(*) and I successfully (with the help of an online tutorial) fulfilled this task by applying the following code:
Code:
int main (void){
int i,n,j;
n=6;
for(i=n;i>0;i--)
{
for(j=n-i;j>0;j--)
printf(" ");
for(j=2*i-1;j>0;j--)
printf(" *");
printf("\n");
}
return 0;
}
But the problem arises now when I want integers instead of * in the output. And the requirement is that they be in following particular order:
Code:
Output:
1111111111
22222222
333333
4444
55
I tried many times manipulating the declarations and definitions and for loops but all in vain. Any help in this regard would be much appreciated.