Enter a year and check if it is a leap year or not
Condition the year is divisible by 4 and 400 but not divisible by 100
#include<stdio.h>
int main()
{
int a,b,c,d; //4 variables are taken in integer as the year cant be in decimal
printf("Enter the year: ");
scanf("%d",&a);//Enter the year
b=(a%4); //Divisible by 4
c=(a%400); //Divisible by 400
d=(a%100); //Divisible by 100
if(b==0) //3Checking if divisible by 4
if(d==0) //2Checking if divisible by 100
if(c==0) //1Checking if divisible by 400
printf("It is a leap year"); //1
else
printf("It is not a leap year"); //2
else
printf("It is a leap year"); //3
else
printf("It is not a leap year");
//If invalid
}