60 535
Assignments Done
97,9%
Successfully Done
In April 2018

Answer to Question #3340 in C++ for mukunda

Question #3340
Take a year as input and check whether it is leap year or not?
Expert's answer
#include <iostream>
using namespace std;

int main()
{
int year;
cout << "Please enter a year: ";
cin >> year;

bool leap = false;
if (year % 400 == 0) leap = true;
else if (year % 100 == 0) leap = false;
else if (year % 4 == 0) leap = true;

if (leap) cout << "This year is leap year." << endl;
else cout << "This year is not leap year." << endl;

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions