Whenever I execute my code, I get a pyramid that is left-aligned instead of right-aligned. I think it is because my for loop for variable j is wrong and therefore none of the spaces will print. I tried to fix it but the pyramid is still left-aligned. My logic for the j for loop was that if per se 8 was the height picked. When substituted for i in i - 1 you get j equals 7 and 7 > or = to 0. Then j would decrease by 1 each time because j will always be greater than or equal to 0.
for (r = 0; r < i; r++)
{
for (j = i-1; j >= 0 ; j--)
{
printf(" ");
}
for (n = 0; n < r+2; n++)
{
printf("#");
}
printf("\n");
}
Height: 5
##
###
####
#####
######