Algorithm to check leap year.
if year % 400 is 0
then is_leap_year
else if year %100 is 0
then not_leap_year
else if year % 4 is 0
then is_leap_year
else not_leap_year
if year % 400 is 0
then is_leap_year
else if year %100 is 0
then not_leap_year
else if year % 4 is 0
then is_leap_year
else not_leap_year
Source Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int year;
printf("\n Enter A Year :: ");
scanf("%d",&year);
if(year%400==0 || year%4==0 && year%100!=0 )
printf("\n Leap Year");
else
printf("Not Leap Year");
#include<conio.h>
void main()
{
int year;
printf("\n Enter A Year :: ");
scanf("%d",&year);
if(year%400==0 || year%4==0 && year%100!=0 )
printf("\n Leap Year");
else
printf("Not Leap Year");
printf("\n Log on to http://www.whatiLearn.info For More ");
getch();
}
getch();
}
Input:
Enter A Year ::2000
Output:
Leap Year
Log on to http://www.whatiLearn.info For More
0 comments:
Post a Comment