Find The Year is Leap Year Or Not
Introduction
In the following C program, we have to find that a year which is given by the user is a leap year or not. We know that if a year contains 366 days or 29 days in February then the year is called a leap year.
Roman general Julius Caesar introduced the first leap years over 2000 years ago. But the Julian Calendar had only one rule: any year evenly divisible by four would be a leap year.
This formula produced way too many leap years but was not corrected until the introduction of the Gregorian calendar more than 1500 years later.
Algorithm:
Step 1: START
Step 2: READ YEAR
Step 3: IF ((YEAR%400==0) OR (YEAR%100!=0)
AND (YEAR%4==0)) THEN go to Step 4
ELSE go to Step 5
Step 4: PRINT THE YEAR IS LEAP YEAR
Step 5: PRINT THE YEAR IS NOT LEAP YEAR
Step 6: STOP
Program to find the year is leap year or not:
#include<stdio.h>
#include<conio.h>
main()
{
int year;
printf("\n Enter the Year:");
scanf("%d",&year);
if((year%400==0)||(year%100!=0)&&(year%4==0))
{
printf("\n The Year is Leap Year");
}
else
{
printf("\n The Year is Not Leap Year");
}
getch();
}
Input:
We Have To Check the Program using the following input-
⦁1st case by giving input as 1900
⦁2nd case by giving input as 2008
Introduction
In the following C program, we have to find that a year which is given by the user is a leap year or not. We know that if a year contains 366 days or 29 days in February then the year is called a leap year.
Roman general Julius Caesar introduced the first leap years over 2000 years ago. But the Julian Calendar had only one rule: any year evenly divisible by four would be a leap year.
This formula produced way too many leap years but was not corrected until the introduction of the Gregorian calendar more than 1500 years later.
Algorithm:
Step 1: START
Step 2: READ YEAR
Step 3: IF ((YEAR%400==0) OR (YEAR%100!=0)
AND (YEAR%4==0)) THEN go to Step 4
ELSE go to Step 5
Step 4: PRINT THE YEAR IS LEAP YEAR
Step 5: PRINT THE YEAR IS NOT LEAP YEAR
Step 6: STOP
Program to find the year is leap year or not:
#include<stdio.h>
#include<conio.h>
main()
{
int year;
printf("\n Enter the Year:");
scanf("%d",&year);
if((year%400==0)||(year%100!=0)&&(year%4==0))
{
printf("\n The Year is Leap Year");
}
else
{
printf("\n The Year is Not Leap Year");
}
getch();
}
Input:
We Have To Check the Program using the following input-
⦁1st case by giving input as 1900
⦁2nd case by giving input as 2008
Discussion:
If efficiency is not a concern computing a year is a leap year or not through the algorithm is successively done.
We check the number with 3 different conditions to confirm that the year is a leap year or not. If the number is divisible by 4 and 400 then it is a leap year and if the number is divisible by 4 and not divisible by 100 then it is also a leap year but otherwise, the year is not a leap year.
3 Comments
14FCC30833
ReplyDeletekiralık hacker
hacker arıyorum
kiralık hacker
hacker arıyorum
belek
83D9678C24
ReplyDeleteTakipçi Satın Al
3D Car Parking Para Kodu
MMORPG Oyunlar
PK XD Elmas Kodu
Viking Rise Hediye Kodu
5F837493E3
ReplyDeleteSkype Show
Whatsapp Åžov
Telegram Show Kanalı