Find Leap Year in C++

In this problem we will learn how to find leap year in C++ program . In Gregorian calendar there are three requirements for leap year. All these requirements must be fulfill for Leap Year .

1. The Year is Divisible by 4.
2. The Year is Divisible by 100.
3. The Year is Divisible by 400.

Source Code   


#include<iostream>
using namespace std;
int main ()
   {
    int year;
    cout<<" \t \t \t Find Leap Year \n \n ";
    cout<<" Enter the Four Digit of Year : ";
    cin>>year;
    cout<<endl<<endl;
    if ( year%4 == 0 || year%400 == 0 || year%100 == 0)
    {
     cout<<"\t \t  Yes! The Year "<<year <<" is a Leap Year "<<endl;
    }
    else
    {
     cout<<"\t \t No! The Year "<<year <<" is Not a Leap Year "<<endl;
    }
    }

Output of the Program


Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment