Check the Leap Year Program In C++

Check the Leap Year Program In C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;
int main()
{
int yr;
cout << "Enter year : ";
cin >> yr;
if(yr % 4 ==0 && yr%100!=0 || yr%400==0)
cout <<yr<< " is Leap year \n";
else
cout <<yr<<" is Not a Leap year\n";
return 0;
}


Check the LeaP Year...
http://www.cbtsam.com/cppl2/cbtsam-cppl2-051.php
exactly what are you trying to ask?
Your code compiles fine in GCC
Your code works.
Only it needs some cleaning up
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;
int main()
{
	int yr;
	cout << "Enter year : ";
	cin >> yr;
	if(yr % 4 == 0 && (yr % 100 != 0 || yr % 400==0)){
	    cout << yr << " is Leap year \n";
	}else{
	    cout << yr <<" is Not a Leap year\n";
	}
	return 0;
}
Last edited on
thanks agt...
Topic archived. No new replies allowed.