So I managed to finish pset1 mario.less but I'm really struggling to understand the logic behind my own code, the confusion comes into play once I get to the part where we begin building the half pyramid. Could someone please explain how the pyramid is being built in plain english for me? I'm specifically confused when it comes to the nested for loops.
int main(void) { int height; int row; int spaces; int hash;
// do-while loop which prompts for height greater than 0 and less than 23
do {
printf("height: ");
height = get_int();
}
while (height < 0 || height > 23);
// drawing the pyramid
// while the amount of rows is less than the height
for (row = 1; row < height; row++){
for (spaces = height - row; spaces > 1; spaces--) {
printf(" ");
}
for (hash = 0; hash <= row; hash++ ){
printf("#");
}
printf("\n");
}
}