Hello.
I'm making a program that asks user to input a day from 1 to 31 (as max day is 31), so when user enters day that is higher than 31 the program will ask to enter the day again until the input is correct. So any day from 1 to 31 should be correct input and break the loop.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main()
{
int day;
cout<<"What is the day?"<<endl;
cin>>day;
if(day>0 && day<32){
cout<<"Today is: "<<day<<endl; }
else {
cout<<"Incorrect day, try again."<<endl; }
return 0;
}
I don't know how to add a loop (and which loop) to this program, so it would ask the day as many times as it needs to user input correct day.
Thank you in advance.