Q26 Write a C program to check leap year.

#include<stdio.h>

int main()

{

        int year;

        printf(“Enter any year to check leap year\n”);

        scanf(“%d”,&year);

        if((year % 4 == 0) && (year % 100 != 0 || year % 400 == 0))

        {

                printf(“This is a leap year\n”);

        }

        else

        {

                printf(“This is not a leap year\n”);

        }

        return 0;

}

Output:

$ ./a.exe

Enter any year to check leap year

2015

This is not a leap year

$ ./a.exe

Enter any year to check leap year

2016

This is a leap year

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.