C++ Program to Find Leap Year by Using Function

Write a program to find if the inputted year is leap year or not by using the concept of function. Make a function that checks if the year is leap year; Source Code,

Write a program to find if the inputted year is leap year or not by using the concept of function. Make a function that checks if the year is leap year;

Source Code,
int isLeapYear(int yr){…}

/*program to find the entered number is leap year or not*/
#include<iostream.h>
#include<conio.h>
/*function decleration*/
int leapyear(int yr);
void main()
{
    int yr;
    cout<<"Enter Year:";
    cin>>yr;
    leapyear(yr);
    getch();
}
/*function defination*/
int leapyear(int yr)
{
     if(yr%400==0 || yr%100!=0 && yr%4==0)
      {
        cout<<"Leap Year";
      }
      else
        {
          cout<<"Not Leap Year";
        }
}
Output:
Enter Year:2015
Not Leap Year

You May Also Like...

Subscribe Us