Leap Year

#include<stdio.h>

int main() {
	int year;
	printf("Enter a year to check that it's a Leap year or not:\n");
	scanf("%d", &year);
	if(year%4 == 0) {

		/* Checking for century year */
		if(year%100 == 0) {
			if(year%400 == 0)
				printf("%d is a leap year!\n",year);
			else
				printf("%d is not a leap year!\n",year);
		}
		else
			printf("%d is a leap year!\n",year);
	}
	else
		printf("%d is not a leap year!\n",year);
	return 0;
}


/* Output */
Enter a year to check that it's a Leap year or not:
2004

2004 is a leap year!

/* ------------------------------- */

Enter a year to check that it's a Leap year or not:
1900

1900 is not a leap year!

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!