## Write a C program in to check whether a year is leap year or not a leap year using Logical Operator

Program in C language to check whether a year is a leap year or not a leap year using Logical Operator. In this article, we will create a program to check whether a  year is a leap year or not. If you want to learn the ‘C’ language check this tutorial https://codedec.com/course/c-programming-tutorial/

## What is a Leap Year?

Leap year is the year that comes in every four years or other words we can say a year multiple of 4. In this interval of leap year, February has an extra day and the month is of 29 days this extra day is called leap day. This happens due to the small extra rotation of the earth and in four years it converted into a day and that day is added in February month.

### Algorithm

• Declare a variable year.
• After that, take input with the help of scanf.
• Check the following condition
• If the year is divisible by 400, it is a leap year.
• If the year is not divisible by 400, but by 100, it is not a leap year.
• If the year is not divisible by 100, but by 4, it is a leap year.
• And at the end, we will display the output  with an appropriate message

## C program in to check whether a year is leap year or not a leap year using Logical Operator

```//leap year
#include<stdio.h>
void main(){
int year;
printf("enter any year to check whether it is leap year :");
scanf("%d",&year);
if(((year%4==0) && (year%100!=0)) || (year%400==0)){
printf("this is a leap year");
}
else{
printf("not a leap year");
}
}
```

### Explanation of the source code

On-Line no:1, we have passed the comment to highlight the program title.

On-Line no:3, creating the main method with void as its return type

On-Line no:4, declaring the variable  to work on it further

On-Line no:5, printing a message

On-Line no: 6, using scanf() function to get input

On-Line no:7, adding conditional statement there to check whether the given year is a leap year or not

On-Line no:8, here we are printing the message that if the condition is true then it is a leap year

On-Line no:10, we here create scope for else part so that if the above is not true then else part will execute further

On-Line no:11, In the end, printing the appropriate output.

### Output

Thus, this is how we create a program in C to check whether a year is a leap year or not using the Logical Operator.