Program to check leap year in C

Source Code

// 13. Program to check leap year
// Arpan Das - CST 2nd Year (VOCLET)

#include <stdio.h>
//#include <conio.h>
//#include <stdlib.h>

void main () {
	/*int is_leap_year(int year) {
		if (year%400==0) return 1;
		else if (year%100==0) return 1;
		else if (year%4==0) return 1;
		else return 0;
	}*/
	int year;
	//system("cls");
	//clrscr();

	printf("\t\t..:: check leap year ::..\n\n");
	
	printf("Enter year: ");
	scanf("%d", &year);
	
	if (year%400==0 || (year%100!=0 && year%4==0))
		printf("\nLeap year");
	else
		printf("\nnot leap year");
		
	//if (is_leap_year(year)==1) printf("\nLeap year");
	//else printf("\nnot leap year");	
	
	//getch();
}

Output

		..:: check leap year ::..

Enter year: 2020

Leap year

		..:: check leap year ::..

Enter year: 2021

not leap year

Leave a Reply

Note: Your email address will not be published. Required fields are marked *