EX - NO:3 Date: Write A Program To Find Whether The Given Year Is Leap Year or Not
EX - NO:3 Date: Write A Program To Find Whether The Given Year Is Leap Year or Not
NO:3 WRITE A PROGRAM TO FIND WHETHER THE GIVEN YEAR IS LEAP YEAR OR
NOT.
DATE:
AIM:
To Write a program to find whether the given year is leap year or not.
ALGORITHM:
1.Start the program.
2.Read Year.
3.IF Year%4=0.
Step-3.1 IF Year%100=0.
Step-3.1.1 IF Year%400=0.
Step-3.1.2 Print “Leap Year”.
Step-3.1.3 ELSE Print “Not Leap Year.
Step-3.2 ELSE Print “Leap Year”.
4.Print “Not Leap Year”.
5.Stop.
PROGRAM:
#include <stdio.h>
#include<conio.h>
void main()
{
int year;
clrscr();
printf("Enter a year: ");
scanf("%d",&year);
if(year%4 == 0)
{
if( year%100 == 0)
{
if ( year%400 == 0)
printf("%d is a leap year.", year);
else
printf("%d is not a leap year.", year);
}
else
printf("%d is a leap year.", year );
}
else
printf("%d is not a leap year.", year);
getch();
}
RESULT:
Thus the program to find whether the given year is leap year or not was executed and the
output was verified.