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!

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. ;)

hi...use three loops one for no of rows..next for spaces and next for printing "*"

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

Show us your code so far, so we can help then.

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. >.<

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.