
C Program to check if a year is leap year or not
Algorithm
Input: Input a year
output: Check if a year is leap year or not
- Start
- Input a numbers say year
- if year % 400 == 0
3.1 Print The year is leap year - else if year % 100 == 0
4.1 Print The year is not leap year - else if year % 4 == 0
5.1 Print The year is leap year - else
6.1 Print The year is not leap year - stop
C Program
#include<stdio.h>
int main( )
{
int year;
printf("Enter a year to check if its leap year or not: ");
scanf("%d", &year);
if (year % 400 == 0) {
printf("%d is a leap year.", year);
}
else if (year % 100 == 0) {
printf("%d is not a leap year.", year);
}
else if (year % 4 == 0) {
printf("%d is a leap year.", year);
}
else {
printf("%d is not a leap year.", year);
}
return 0;
}
Note: This Program was created using visual studio code. The Program file can be downloaded by clicking here
Comments