-
While statement
Hey guys I am having trouble with my while statement:
if (id >= 1 && id <= 499)
{
cout << "\nPlease enter hours worked: ";
cin >> hrs;
}
while (id <= 0 && id >= 500)
{
clrscr ();
cout << "\nYou must enter a valid ID from 1 through 499.";
cout << "\nPlease enter hours worked: ";
cin >> hrs;
}
How would I get the the while statement to loop? When I run it, it freezes up if, the ID is 0 or less, 500 or more.
-
I think you mean:
while(id<=0 || id>=500)
as id cant be both conditions at the same time.
-
> while (id <= 0 && id >= 500)
...
> cin >> hrs;
Inputting id would be a good idea, otherwise you'll never get out again
-
thanx