UPDATE Good afternoon; would you please help me to finish this; I don't know how to put correctly the spaces of the pyramid.

int main (void)


int row;
int space; 
int hash;

for (row = 1; row <= 5; row++) // 

    for (hash = 0; hash <= row; hash++)


    for (space = 0; space <= row; space++)


    printf("\n"); // new line in per row

enter image description here


Think about what you are printing. Each line has one more space than the previous line. It's supposed to have one less space than the line before.

Remember too, a for loop doesn't have to start at 0 and increment the index. It can start at any number and decrement or subtract.

So, think about how you can print a lot of spaces on the first line and print one less on each line that follows.

Also, take note that the first line of every pyramid has 2 hashes, not one.

If this answers your question, please click on the check to accept. Let's keep up on forum housekeeping. ;-)

  • Thank you 4 your answer. Now the problem is how to "invert" the pyramid. Honestly I got no idea how to figure out it. Look at the updated thread.
    – Paul_1898
    Oct 8 '15 at 21:49
  • There are still several pieces missing. All you did was rename some variables and print the hashes before you printed the spaces. You are also not taking user input for how many rows, as specified in the assignment. You should reread the assignment carefully,and review the class videos. All the info and techniques are in them. Next, break the assignment down into smaller pieces - how to get user input, how to print the correct number of lines, how to print the right number of hashes and how to print the right number of spaces - and get each one working first before starting on the next.
    – Cliff B
    Oct 8 '15 at 22:02
  • I will keep it in mind thank you :-)
    – Paul_1898
    Oct 9 '15 at 0:24
  • I found the relationship between the space and the height (space = height - 1) I'm done with this pyramid thank you Cliff B!
    – Paul_1898
    Oct 9 '15 at 18:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .