i know this may have been asked quite some times but i have gone through many of the answers here and on other websites and i just can't understand them. the pyramid is printing OK but it is inverted, i tried exchanging the " " with the "#" didn't work, tried exchanging the statements also didnt work. please help, thanks! int main(void) { int height = 0; int spaces =0; int hashes= 0; int rows =0; do { printf("How many spaces?"); height = GetInt(); } while (height <0 || height >23);

for(rows = 0; rows< height; rows++) { for(hashes=rows;hashes<=height;hashes++){ printf("#"); } for(spaces=height-1;spaces>=height;spaces--){ printf(" "); }


} }

1 Answer 1


There are several problems, but this is the start of learning to work through them. My suggestion to you is to attack the assignment by breaking it down into small parts and work on one part until it's right, before moving on to the next part. In this problem, first get the size of the pyramid. Second, print something that has the correct number of lines. Third, print out the right number of hashes, not worrying about the spaces, and finally, print out the right number of spaces (and put them in the right place.)

This should get you started.

You must log in to answer this question.

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