My code says invalid if I input a valid number of days and it prompts the user again to enter days but it reads the first input
https://code.sololearn.com/c0yilUYhkwkq/?ref=app The loop was supposed to keep reading input until a numeric input was given. It allows max of 3 invalid inputs (letter etc.) and it will exit the loop when <bad_inputs> reaches 3. After the loop is done, there we check whether or not <days> was valid. If it is valid, then continue with calculation. std::cout<<"\nPlease enter valid days:"; do { do { std::cin>> std::setw(1)>> days; std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n'); if(days >= 0|| days <= 31) { bad_inputs++; std::cin.clear(); } if (bad_inputs) { std::cout<<"You have entered an invalid number"; std::cout<<"Please enter a number again:"; } }while (!(days >= 0|| days <= 31)&& bad_inputs <3); std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n'); }while ((days >= 0|| days <= 31)&& bad_inputs <3);