C++ Function to determine whether the year is a leap year or not.Any year is entered through the keyboard.

//C++ Function to determine whether the year is a leap year or not.Any year is entered through the keyboard.

#include <iostream>
using namespace std;
int find(int a);
int main() 
{
	int year,leap;
	cout << "Enter an year : ";
	cin >> year;
	leap=find(year);
	if(leap==1)
		cout << year <<" year is leap year ";
	else
		cout << year <<" year is not a leap year ";
              return 0;
}
int find(int a)
{
	int i=0;
	if((a % 4 && a % 100 && a % 400)==0)
		i=1;
	else
		i=0;
	return i;
}

Output :
Enter an year : 2016

2016 year is leap year



Leave a comment