C Program to find the leap year using if-else statement
Write a program to find the leap year in C Language?
Before writing a C program for leap year, let’s see what is Leap year and what is the logic behind, to write a program.Leap year has 366 days in year with 29 days in February.It is a year which comes once every 4 years.
Logic:
If a year is perfectly divisible by 4, it means that is a leap year and If the year can be evenly divided by 100, it is NOT a leap year, unless the year is also evenly divisible by 400. Then it is a leap year.To understand more about the logic for leap year, read Leap year article at Wikipedia.
Here is source code of the C program to check a given year is leap year:
#include<stdio.h>
int divide(int num)
{
if(num%4==0)
{
printf(“%d is leap year”,num);
}
else
{
printf(“%d is not a leap year”,num);
}
return (num);
}
int main()
{
int a;
printf(“enter the value of a”);
scanf(“%d”,&a);
divide(a);
return 0;
}
Stay in touch with us and learn more about C Programming Language
About us:
Professional Training Institute is one of the top Embedded System training Institute in Bangalore, Our unique training practical based training approach makes every student as knowledgeable and experienced. Our student Practical hands on training in Embedded system makes student employable. And also till now are having 100% placement records in our Embedded system.