Saturday, 6 September 2014

Find Leap Year in C++

Structure of the Problem Requirements 

In this problem we will learn how to find leap year in C++ program . In Gregorian calendar there are three requirements for leap year .

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

All these requirements must be fulfil to prove a year a Leap Year . Here is the source code of this problem which help you in better understanding.

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 it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

2 comments: Post Yours! Read Comment Policy!▼
Important Note:
We have Zero Tolerance to Spam. Chessy Comments and Comments with Links will be deleted immediately upon our review.

  1. You may want to check what a leap year is before posting such atrocity:
    https://en.wikipedia.org/wiki/Leap_year

    ReplyDelete
    Replies
    1. thanks stranger for your interest . Dear we just build leap year program logic and explain it with few words .. Definitely Wikipedia has rich content about it. keep visiting

      Delete