Hi, I'm fairly new to C and I'm making some triangles. The problem I have is that I need to make this:
Code:
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
Here is the code I've been playing around with:
Code:
for (row = 10; row >= 1; row--)
{
for (spaces = 10; spaces <= row; spaces++)
printf(" ");
for (column = 1; column <= (row*2-1); column++)
printf("*");
printf("\n");
}
I've already been through loads and loads playing with different numbers etc but I can never get it to look like above. What am I supposed to do?
While I'm here, for this triangle:
Code:
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
I used this code:
Code:
for (row = 1; row <= 10; row++)
{
for (column = 1; column <= (row*2-1); column++)
printf("*");
printf("\n");
}
Notice I missed out the spaces loop. Is that OK or should I include it (even though it does nothing).
Thanks in advance