Condition for the leap year
Leap Year
Not a leap year
c program to check leap year
#include int main() { int year; printf("Input a year: "); scanf("%d", &year); if (year % 400 == 0||year % 4 == 0) { printf("Leap Year"); }else{ printf("Not a leap year"); } return 0; }
Output:
Input a year: 2018
Not a leap year
#include int main() { int year = 2020; if ((year%400 == 0) || ((year % 4 == 0) && (year % 100!= 0))){ printf("%d is a leap year", year); }else{ printf("%d is not a leap year", year); } return 0; }
Output:
2020 is a leap year
0 0Please Login to Post the answer