Tuesday, 26 September 2017

write a program to check leap year or not in c++


C++ Program to Check Leap Year

This program check given number is year leap or not.

You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop



Leap year that is given number divided by
4.if number is perfectly divided to 4 its also
known as leap year.
leap year such as 2004,2008,2012,2016,2020
2024,2028





Example: Check given a year is leap year or not


#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int y;

    cout << "Plz Enter a year: ";
    cin >> y;

    if (y % 4 == 0)
    {
        if (y % 100 == 0)
        {
            if (y % 400 == 0)
                cout << y << " leap year.";
            else
                cout << y << "not leap year.";
        }
        else
            cout << y << " leap year.";
    }
    else
        cout << y << " not leap year.";

    return 0;
}
Output

Plz Enter a year: 2012
2012 leap year.





The  people who want to learn programming language.this website very beneficial for those people.

No comments:

Post a Comment