assholenachos assholenachos - 7 months ago 36
C Question

Why doesn't my do while loop work? I put a switch after it and the switch works

It was supposed to get user input but it should prompt the user again for an input if n < 0 and n>23 but all it seems to do when i give it a negative number is it stops working. Here's what it looks like

int n = 0;
printf("Enter positive height less than 23: ");
n = GetInt();
while(n <0 && n>23);
//a list of cases for every number from 0 to 23}

the switch works just fine. My only problem is with the condition in the while.


try changing your loop condition to

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