# infinite loop for mario.c

I'm almost there in solving the pset1 of cs50 mario.c the problem in my code is when i enter a number more than 1 and less than 23 , it goes in infinite loop and prints spaces all the way without stop. I'm quite sure the problem in the condition of my "spaces for loop" but i don't know where exactly the problem is if anyone can provide me tips to overcome this problem , it will be great ! thanks !

``````#include <cs50.h>
#include <stdio.h>

int main(void)
{
int m ;
int row , hash , space ;
// we will need to prompt the user at least once so , do-while loop
do
{
printf("Height: ");
m = GetInt() ;
}
while ((m < 0) || (m > 23)) ;

//Drawing the pyramid
for (row = 0 ; row < m ; row ++)
{
for (space = 0 ; space < (m-1) ; space--)
{
printf(" ");
}
for (hash = 0 ; hash < ((m+1)-(m-1)) ; hash++)
{
printf("#");
}
printf("\n");
}
}
``````

if you followed the logic of your code, you'd find that if you entered a number that is > 1 for the height, `m - 1` would become at least 1. since `m - 1` will always produce the same value and `spaces` is initialized with a `0` and gets decreased after each iteration of the for loop, the condition `spaces < (m - 1)` will be always `true` and therefore, an infinite loop.
as a side note, you probably wanna give your variables more descriptive names. it's generally a bad practice to give your variables names like `m`. you also probably don't wanna make your code difficult to understand by placing all sorts of magic arithmetic expressions (e.g., `m - 1` and `(m + 1) - (m - 1)`.