Write a program to find whether a given year is a leap year or not using nested if-else.
C Program
#include <stdio.h>int main(){int year;printf("Enter a year : ");scanf("%d", &year);if (year % 100 == 0){if (year % 400 == 0){printf("Leap Year\n");}else{printf("Not a leap year\n");}}else if (year % 4 == 0){printf("Leap Year\n");}else{printf("Not a leap year\n");}return 0;}
Example:
Enter a year : 2020
Example:
Leap Year
No comments:
Post a Comment