Write an algorithm to check whether entered year is leap year or not using
operator
Answers
Answer:
It is evenly divisible by 100. If it is divisible by 100, then it should also be divisible by 400. Except this, all other years evenly divisible by 4 are leap years.
Explanation:
Answer: This is the C program code and algorithm for checking whether the given year is a leap year or not
Aim:--
Write a C program to check whether the given year is a leap year or
not.
Step 1 : Start.
Step 2 : Read Year.
Step 3 : If year mod 400 is 0, print the year is a leap year & go
to step 7.
Step 4: If year mod 100 is 0, print the year is not a leap year &
go to step 7.
Step 5: If year mod 4 is 0, print the year is a leap year & go to
step 7.
Step 6: print the year is not a leap year.
Step 7: Stop.
Program code -
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( )
int year;
printf("Enter the year: ");
scanf("%d",&year);
if(year%400==0)
printf("The year is a leap year");
else if(year%100==0)
printf("The year is not a leap year");
else if(year%4==0)
printf("The year is a leap year");
else
printf("The year is not a leap year");
getch( );
}
Output -
Enter the year : 2012
The year is a leap year
- Please make me brilleant
- Thanks and vote me