Hello, I am prompting for user input and I want the program to ONLY execute if the input is an integer between 1 and 23 and if its not repeat the prompt. However if I give an integer below 1 the function stops and does not execute and if I give an integer above 23 the function still executes.
Code:
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int height;
// prompts for user input & checks for correctness
do
{
printf("Height: ");
height = GetInt();
}
while (height<=0 && height>23);
// handles the line variable
for(int line=1;line<=height;line++)
{
// calculates number of spaces
for(int space=1;space<=(height-line);space++)
{
printf(" ");
}
// calculates number of hashes
for(int hash=1;hash<=(line+1);hash++)
{
printf("#");
}
// starts new line
printf("\n");
}
return 0;
}