Check Leap Year Program Example using CPP

  1. Home
  2. Tutorials
  3. CPP
  4. CPP Programs
  5. If Else Statement
  6. Program

Source Code

#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    // Variable Declaration for input
    int y;

   // Taking Yesr input in Variable y
    cout<<"Enter Number: ";

   // Checking Leap year using if else statement

    if ( y % 4 == 0 )
        cout<<"Leap Year \n";
        cout<<"Not a Leap Year \n";
    return 0;


check whether a given year is leap or not using if else statemenet in c++Working

This program declare one variable of int type to store year input. This variable is named as y. After this input statement having cin is used to get input from user. A year is called leap year if it is divisible by 4. Mean if we take remainder of year by 4 and it gives 0, then it will called leap year. For this purpose we use if else statement in source code.

Example of Leap Years:

Some examples of leap years are as below as these are completely divisible by 4.

2000, 2004, 2008, 2016, 2020............


Login to TRACK of Comments.