Requirements:
(1) Please enter the value of a year through the keyboard.
(2) Please program to determine whether the entered year is a leap year.
(3) The conditions for a leap year are: divisible by 4 but not divisible by 100; or divisible by 400.
#include <iostream>
using namespace std;
int main()
{
int year;
cout<<"Enter the Year: ";
cin>>year;
if ((year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0))
{
cout<<"It is a Leap Year";
}
else
{
cout<<"It is not a Leap Year";
}
}
Comments
Leave a comment