I am very new to c++ and would like some help writing this out. I am not asking for you to write it out for me. I'm just asking for someone to help me start it.
So the program I have to write is if someone picks the years from 400 to 2400 is it going to be a leap year using the if else statement and here is what i have so far.
begin
Prompt for year in range
Read year
If (year in range)
If (year %4!=0)
Output year is not a leap year
Else (if year%100!=0)
Output year is a leap year
Else (if year%400!=0)
Output year is a century year but not a leap year
Else output year is a century leap year
Else
LeapYear
if (Year % 4 !=0)
cout<<"Year is not a leap year\t"
else (Year % 100 !=0 )
cout<<"year is also not a leap year\t"
else (Year % 400 !=0)
cout<<"year is a centyrt year but not a leap year"
else output year is a century leap year ;
//main body
int main ()
{
//local identifiers
int Years,LeapYear;
//input module
cout<<"please input year that you would like to check:\t";
cin>>Years;
If you wanted it to be a continuous program you could write a do while statement that envelopes your main code, so you wont need to reopen the code every time you want to enter a year.
1 2 3 4
do
{
Run code
}while(Years >= 400 && Years <= 2400)
.
As for the if statements, they didnt seem to make sense. Are you trying to do something like this?
1 2 3 4 5
LeapYear
if(Year % 4 == 0)
cout << "Year is a leap year";
else
cout << "Year is NOT a leap year";