#include <stdio.h>
#include <cs50.h> //since get_int function used
int main(void) {
int t;
do {
t = get_int("height");
}
while (t < 1 || t > 8);
for (int y = t; y > 0; y--) //will take care of changing rows
{
for (int i = y - 1; i > 0; i--) //will take care of printing blank space as part of loop with no. of blank spaces in each row = height - row no.
{
printf(" ");
}
for (int j = 0; j < t - y + 1; j++) //will take care of printing # as part of loop with no. of # = row no.
{
printf("#");
}
printf("\n"); //will take care of changing rows.
}
}
The assigned values to y, i, and j in loops might need some replacement and might not come in first shot. First check if for say 5 height, you are getting 5 rows. Next, focus on blank space. You might initially replace blank space with . (dot) for better visibility. After getting blank space in correct order, focus on #.[learn_press_profile]