Episode 8: Leap Year Program

Share this content:

Leap Year in C Programming

 

Do you know what Leap Year is? No, then go to this website (https://www.mathsisfun.com/leap-years.html) immediately.

Now you came to know the logic behind the leap year. Simply code it using the same logic.

 

Code: 

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

void main()
{
int y;
printf(“Enter the Year:”);
scanf(“%d”,&y);

if(y%400 == 0)
{
printf(“It is a Leap Year!”);
}
else if(y%100==0)
{
printf(“It is Not a Leap Year!”);
}
else if(y%4==0)
{
printf(“It is a Leap Year!”);
}
else
{
printf(“It is Not a Leap Year!”);
}

getch();
}

 

Output:

Enter the Year:2010
It is Not a Leap Year!

Enter the Year:2008
It is a Leap Year!

Share this content:

Leave a Reply

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

TechGenBlog © 2017 | With ❤ From India