Help :)


start:

cout << " | Enter Employee Sick Leave: \t\t\t";
cin >> sickleave[i];

if(sickleave>0
{
cout<<"Greate";
}
else if(sickleave=0) //check for negative number
{
cout<<"0";
}
else
{
cout<<"\t | Invalid Input Or Enter Positive Number: "<<endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
goto start;
}


when i put alpha character it will infinite loop? why the numeric valadition is not working.. thank u
This code does not compile.

'check for negative number' assigns 0 to sickleave.

when i put alpha character it will infinite loop? why the numeric valadition is not working.. thank u
You need to check whether cin is bad. If you enter non numeric characters and sickleave is numeric, sickleave will not be changed and cin will reside in an error state until cin.clear();
Topic archived. No new replies allowed.