logo image

C Language program to take a year as input and tells whether it's a leap year or not

Views: 14

Following program shows you how take a year as input and tells whether it's a leap year or not.

#include <stdio.h>
int main() {
	int input;

	printf("Enter a year:");
	scanf("%d", &input);

	if (input % 4 == 0) {
		if (input % 100 == 0) {
			if (input % 400 == 0) {
				printf("%d its a leap year", input);

			} else {
				printf("%d its not a leap year", input);
			}

		} else {
			printf("%d its a leap year", input);
		}
	} else {
		printf("%d its not a leap year", input);
	}
}

Output:

Example1:

Enter a year: 2012
2012 its a leap year 

Example2:

Enter a year: 2019
2019 its not a leap year 
We are looking for Interns!
Send your resumes to
[email protected]