I'm new to programming and was hoping I could get some help. I'm attempting to create a 'do while' loop in C as part of my CS50 problem sets. I'm attempting to use two different conditions under 'while', but for some reason they are not being recognised. Here's my code
#include <stdio.h>
#include <cs50.h>
int get_height(void);
int main(void)
{
int height = get_height();
printf("you picked %i\n", height);
}
int get_height(void)
{
int height;
do
{
height = get_int("enter height\n");
}
while (height > 8 && height < 1);
return height;
}
I'm trying to force the user to type an integer under 8, but above 0. If I take out either one of the two conditions, that single condition works. If I try to use both conditions however, the code compiles and runs but it doesn't force me to enter a number within the parameters specified. I can just enter any number and it will be accepted. Can anyone help?
EDIT: I'm embarrassed. I misunderstood how AND operators work.