So I'm trying to make a function that determines whether a year is a leap year or not. However, I want to give the user only 2 chances to input a year and then exit the program afterwards instead of just looping the "Try again" like it does in my current code. If anybody could help point out what I'm doing wrong, I'd greatly appreciate it. Thank you!
int tries = 2;
while (tries--)
{
if user enters a year (which is any valid integer, really)
break;
cout << "dat aint no number!\n";
}
if (tries)
{
cout << "foo u foo -- i give up!\n";
return 1;
}
cout << "good job!\n" << year << " is " << (isLeap(year) ? "" : "not") << " a leap year.\n";