I am trying to use the GetInt() function on my variable x and repeat the do while loop if the answer is not between 1-23 but I keep getting undeclared identifier error
#include <stdio.h>
#include <cs50.h>
int main(void)
{
do
{
printf("Pleae enter a number between 1 and 23\n");
int x = GetInt();
printf("the number is %d\n", x);
} while (x <= 0 && x > 23);
}
errors
mario.c:11:14: error: use of undeclared identifier 'x'
} while (x <= 0 && x > 23);
^
mario.c:11:24: error: use of undeclared identifier 'x'
} while (x <= 0 && x > 23);
^
2 errors generated.
then i tried adding int x = 0 and got the following
#include <stdio.h>
#include <cs50.h>
int main(void)
{
int x = 0;
do
{
printf("Pleae enter a number between 1 and 23\n");
int x = GetInt();
printf("the number is %d\n", x);
} while (x <= 0 && x > 23);
}
error
./mario.c: line 4: syntax error near unexpected token `('
./mario.c: line 4: `int main(void)'