0

guys.. i hope you could help me out here..
we are currently in iterative and conditional statements..

problem is making a pyramid using asterisks.

for example, if the user input 6, that would be the height of the pyramid, while the body starts at 1 and increases by 2 each line.

i.e. input = 5
xxxxxxx*
xxxxxx***
xxxxx*****
xxxx******
xxx********

x - is the spaces. :)
thanks advance!

Edited by kyumi419: n/a

4
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by kyumi419
0

Tip: learn how to use code tags and you can leave spaces as spaces instead of replacing them with x's. And folks will appreciate it when you post your code within code tags. ;)

0

yeah.. i got that concept of three loops, however, i still don't come up to a correct output..

0
main()
{
int x,y,z,n;
clrscr();
scanf("%d", &n);

for(x=1;x<=n;x++)
{
                  for(y=x;y>=0;y--)
                  {
                         for(z=1;z<=y;z++)
                        {
                         printf(" ");
                        }
                   }
}

for(x=1;x<n*2-1;x=x+2)
{
              for(y=1;y<=x;y++)
             {
              printf("*");
              }
             printf("\n");
}

getch();
}

that's so far.. ^^ thanks.. just a rookie here, i don't have the idea of posing the codes, hehe.. i really want to solve it. >.<

Edited by John A: added code tags

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.