while (check=1)
{
cout<<"Please enter the number of people: "<<endl;
cin>>people;
if (people<6000&&people>0);
{
check=0
}
else
{
cout<<"Please enter a number between 0 and 6000"<<endl;
}
}
Even if the conditions are met, the check should be set to 0 and the loop should end but it does not seem to end?
you had put the semicolon in front of 'if condition' . It is wrong . It is one type of function definition semi colon should not be there. And infront of 'check=0' semi colon should be there . Compiler is waiting for end of the statement.
while (check == 1)
{
cout<<"Please enter the number of people: "<<endl;
cin>>people;
if (people<6000&&people>0)
{
check=0;
}
else
{
cout<<"Please enter a number between 0 and 6000"<<endl;
}
}
(Insert if i had a dollar for everytime i meant to put = instead of == here)
Generally you should use the built in formats for code, because it's easier for people to show you what line of code has a problem, for this situation, you have an error on line 1 check = 1 is the incorrect syntax, as it will always evaluate to true, hense your error never ending, as well I don't understand how you compiled, because check = 0 did not have a semi colon on line 7, and on line 5 you have an out of place semicolon, maybe that was meant to be line 7. Your code should work just fine now though.