4 int main(void)
5 {
6 int height;
7 int rows;
8 int spaces;
9 int hash;
10
11 do
12 {
13 printf("For the height, Choose a number from 0 to 23?: ");
14 height = GetInt();
15 }
16 while ((height < 0) || (height > 23));
17
18
19 for (rows = 1; rows <= height; rows++)
20 {
21 for (spaces = rows + 1; spaces <= height; spaces++)
22 {
23 printf(" ");
24 }
25 for (hash = spaces + 1; hash >=height; hash--)
26 {
27 printf("#");
28 }
29 printf("\n");
30 }
31 return 0;
32 }
Alright guys, so I'm running into some issues with my code. When I input the height such as 7, this is what I get:
I'm trying to make the pyramid out of hashes that aligns to the right of the spaces and is equivalent to the inputted height. As you can see here, I'm having difficulty forming the pyramid of hashes. However, the spaces seem to be working. I know the issue is right in front of me, but as of now, I can't figure it out. Can someone see where the flaw is in my code as to why the hashes will not make the desired pyramid?