0

In mario less pset1 when I run check50 the only error I get is the program does not handle 0 correctly. I have tried return 0; and repositioning things. I feel like I have to tell "C" to treat 0 and anything less than 0 as a char and not an integer. Is this the correct thinking? Here is my code:

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

int main(void)
{

int height = 0;

do
{
printf("how high is the pyramid: ");
height = get_int();
}


while (height < 1 || height >23);

for(int r = 1; r <= height; r++)
{
for(int spc = 0; spc <=height-r-1;spc++)
{
printf(" ");
}
for(int brick = 0; brick < r+1; brick++)
{
printf("#");
}
printf("\n");
}
return 0;

}

1 Answer 1

0
while (height < 1 || height >23);

Is the statement that is causing problems the right thing is:

while (height < 0 || height >23);

According to the specifications

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .