Recently I stuck in this particular Pset. It appears I followed all the instructions, but when I try to run this code it simply doesn't print anything. Any suggestions? Thanks, here's my cOdE:

include include

int main(void) {

int height;
int row;
int hash;
int space;

    printf("Gimme the height of the pyramid. Choose numbers between 0 to 23\n");
    height = GetInt();
while (height < 0 || height > 23);

for (row = 0; row < height; row++) // master loop
    for (space = height - 1; space < height; space--) // it prints infinite "_"

    for (hash = height + 1; hash > height; hash++)



  • i count 9 brackets s/b 8 or 10, but i could be wrong
    – user9922
    Oct 16, 2015 at 12:28

1 Answer 1


A FOR loop has three clauses, the initialization clause, the test clause and the increment clause, separated by semicolons. The test clause MUST BE TRUE for the for loop to execute a cycle. Look at your for loops, for example:

    for (space = height - 1; space > height; space--)

You set space initially to something less than height and it immediately tests to see if space is greater than height. This means that this loop will never execute. Same problem with the hash loop.

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

  • Thank you 4 your ans. Now somethin' funny happened I changed the "<>" signs and it prints infinite "_". Any suggestion? (See my update code above)
    – Paul_1898
    Oct 8, 2015 at 16:51
  • When you do that, it will keep looping until the test condition is false, in other words, until space == height. Since space is less than height to start and gets decremented, it will never test false. You need to think about these index variables - what you initialize them at, what the test is, and how and which direction they're being incremented.
    – Cliff B
    Oct 8, 2015 at 17:07

You must log in to answer this question.

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