Whether a given year is Leap Year or Not|Learnerspage

0
43
Whether a given year is Leap Year or Not

#include<stdio.h>
#include<conio.h>
void main()
{
int year; // Initializing a variable year
printf(“Enter a year \n”);
scanf(“%d”, &year); // Scanning the variable year
if ((year % 400) == 0) // Divide year with 400 and if reminder is 0 then it’s a leap year
printf(“%d is a leap year \n”, year);
else if ((year % 100) == 0) // Divide year with 100 and result 0 then it is not leap year
printf(“%d is a not leap year \n”, year);
else if ((year % 4) == 0) // Divide year with 4 and if reminder is 0 then it’s a leap year
printf(“%d is a leap year \n”, year);
else
printf(“%d is not a leap year \n”, year); // For any other case not leap year
getch();
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here