Any year is entered through the keyboard, write a program to determine whether the year is leap or not. Use the logical operators && and ||.
#include<iostream>
using namespace std;
int main()
{
int year;
cout << "Enter year: " << endl;
cin >> year;
if(year % 4 == 0 && year % 2 == 0)
{
cout << "Leap year: " << endl;
}
else{
cout << "Not leap year: " << endl;
}
}
// above program also written as
// if(year % 4 == 0)
// cout << "Leap year " << endl;
// if(year % 100 == 0 && year % 400 == 0)
// cout << "Leap year" << endl;
// else
// cout << "not leap year" << endl;
0 comments:
Post a Comment
If You Have Any Problem While Downloading Comment Below