1. You are provided with the isLeapYear() function which is already declared and defined for you. 2. Your task is to ask the user for a year and then call the isLeapYear function to check whether the year is a leap year or not. Input 1. Year to be checked Output If a certain year is a leap year, print "is a leap year" Otherwise, print "is not a leap year" Sample Output: Enter·year:·2020 2020·is·a·leap·year This is the given code: #includeusing namespace std; int isLeapYear(int); int main(void) { // TODO: Write your code here return 0; } int isLeapYear(int n) { if( (n % 4 == 0 && n % 100 != 0) || (n % 100 == 0 && n % 400 == 0) ) { return 1; } return 0; }
The Answer to the Question
is below this banner.
Can't find a solution anywhere?
NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?
Get the Answers Now!You will get a detailed answer to your question or assignment in the shortest time possible.
Here's the Solution to this Question
#include <iostream>
using namespace std;
int isLeapYear(int);
int isLeapYear(int n)
{
if((n % 4 == 0 && n % 100 != 0) || (n % 100 == 0 && n % 400 == 0))
{
return 1;
}
return 0;
}
int main(void)
{
// TODO: Write your code here
int Yr,Flag=1;
while(Flag)
{
cout<<"\n\tEnter a Year: "; cin>>Yr;
if(isLeapYear(Yr)) cout<<"\n\t"<<Yr<<" is a leap year.";
else cout<<"\n\t"<<Yr<<" is not a leap year.";
cout<<"\n\tPress 1 to continue or 0 to QUIT: "; cin>>Flag;
}
return 0;
}