Write a program that uses a function to check whether a given year is a leap year or not.

C Programming Language Function in C Language (Article) Function in C Language (Program)

890

Program:


#include <stdio.h>

int leap_yr(int);
int main(void)
{

	int year, yes;
	printf("\n Enter the Year: ");
	scanf("%d",&year);
	yes=leap_yr(year);
	if(yes)
		printf("\n It is a leap year");
	else
		printf("\n It is NOT a leap year");
	return 0;

}


int leap_yr(int yr)
{
	if((yr%4==0)&&( yr%100!=0)||yr%400 ==0)
			return 1;
	else
			return 0;

}
 

Output:

 Enter the Year: 2100

 It is NOT a leap year
 

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.