I was doing some hackerrank practice and I couldnt solve it. I am newbie any ideas to solve this problem?
Please write a software program that prints the following pyramid pattern to the screen. Your program should get a number “n” as an input and should print n lines of the pyramid. (For example if your input is 4, then the following output is expected.)
(You can choose any programming language that you want.)
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
#include<stdio.h>
int main()
{
int i,j,k,l=1;
for(i=1; i<=5; i++)
{
for(j=4; j>=i; j--)
{
printf(" ");
}
for(k=1; k<=l; k++)
{
printf("%d",k);
}
l = l+2;
printf("\n");
}
return 0;
}
Clanguage but you have added thepythontag. Editing the tag to addCwill likely get you more help.