Computer Science, asked by febin001, 1 month ago

Write a C Program to check for a leap year using If?​

Answers

Answered by vumsuma
1

Explanation:

Leap year program in C:

First of all, it is important to know what is leap year?

Generally, a year has 365 days in a year, but a leap year has 366 days which comes after four year. Below are some points related to leap year:

●A leap year is a year, which is different than a normal year having 366 days instead of 365.

●A leap year comes once in four years, in which February month has 29 days. With this additional day in February, a year becomes a Leap year.

●Some leap years examples are - 1600, 1988, 1992, 1996, and 2000.

●Although 1700, 1800, and 1900 are century years, not leap years.

Below conditions are used to check that year is a leap year or not.

#include<stdio.h>

#include<conio.h>

void main() {

int year;

printf("Enter a year: ");

scanf("%d", &year);

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

{

printf("%d is a leap year", &year);

} else {

printf("%d is not a leap year", &year);

}

getch();

}

See the below outputs for different input values:

Test 1:

Enter a year: 2004

2004 is a leap year

Test 2:

Enter a year: 1700

1700 is not a leap year

Similar questions