A leap year program in C

Enter a year to find out it’s leap year or not !

Explanation about the formula: http://www.infoplease.com/spot/leapyear1.html

#include<stdio.h>
int main()
{

int year,remainder_4,remainder_100,remainder_400;
    printf("Enter your year:\n");
    scanf("%d",&year);
    remainder_4=year%4;
    remainder_100=year%100;
    remainder_400=year%400;

    if((remainder_4==0&&remainder_100!=0)||(remainder_400==0))
        printf("It's leap year");
    else
        printf("It's not leap year");

return 0;

}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.