0

I am confused. How do you construct the basic left aligned pyramid, then add the spaces to the spaces to the left eventually? I don't understand how to get print 2# then next line print 2++ #

include

include

int main(void) { int height;

do { printf("height? \n"); height = get_int();

} while (height< 0 || height > 23);

for (int i = 0; i < height; i++) { for (int space = 0; space < i ; space++) { printf(" "); } for (int hash = 0; hash

}

}

1 Answer 1

1

You have to imagine that you are writing the pyramid from left to right, top to bottom, and can't "go back". So you have to print the spaces before you print the hashes.

You must log in to answer this question.

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