Skip to main content

Write a C C++ program to check whether given year is leap or not


Flowchart
Draw a flowchart to check whether given year is leap or not

Coding in C

#include<stdio.h>
int main()
{
    int y;
    printf("Enter an year: ");
    scanf("%d",&y);
    if(y%4==0&&y%100!=0||y%400==0)
    {
        printf("Leap year");
    }
    else
    {
        printf("Not a leap year");
    }
    return 0;
}

Coding in C++

#include<iostream>
using namespace std;
int main()
{
    int y;
    cout<<"Enter an year: ";
    cin>>y;
    if(y%4==0&&y%100!=0||y%400==0)
    {
        cout<<"Leap year";
    }
    else
    {
        cout<<"Not a leap year";
    }
    return 0;
}

Output
Write a C++ program to check whether given year is leap or not