Q:

Leap Year Program in C [Logic, Examples & Output] | IF-ELSE

belongs to collection: If/Else C Programs to Practice

0

 Write a Leap Year Program in C to check whether the year is Leap Year or Not, using IF-ELSE Statements. The user must enter the Year and Program should Prompt the message "The Entered Year is Leap Year or Not". Leap years have total 366 numbers of days and a February 29. If we need to find which year is Leap Year or not.

Leap Year Examples:

  1. 1992: Leap Year
  2. 2002: Not a Leap Year
  3. 2016: Leap Year
  4. 2100: Not a Leap Year
You can modify this code to find the next or previous Leap Year if the User Entered the current year or you can also find the list of all the Leap Years in a Century

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

    printf("Enter a Year: ");
    scanf("%d", & year);

    if (year % 4 == 0) 
	{
        if (year % 100 == 0) 
		{
            if (year % 400 == 0)
                printf("%d is a Leap Year.", year);
            else
                printf("%d is Not a Leap Year.", year);
        } else
            printf("%d is a Leap Year.", year);
    } 
    else
        printf("%d is Not a Leap Year.", year);
    return 0;
}

 

Output:

Enter A Year: 2200

2200 Is Not a Leap Year.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program Date Validation Using If Else Statements... >>
<< C Program For Check Number Is Even Or Odd...