Leap Year

Learn and Trouble Shoot Problems Related to C-Language here.

Leap Year

Unread postby rajeevmahura » Thu May 22, 2008 6:34 pm

#include<stdio.h>
#include<conio.h>
void main()
{
int year;
clrscr();
printf("\aEnter the year you want to cheak");
scanf("%d",&year);
if(year%4==0)
{
printf("\aThe year you have chosen is a leap year");
}
else
printf("\aThe year you have chosen is not a leap year");
getch();
}
--Regards--
Rajeev Mahura
Servers & Storage Professional
http://about.me/rajeevmahura
User avatar
rajeevmahura
 
Posts: 144
Joined: Tue May 20, 2008 5:22 pm
Location: Bangalore | New Delhi
Full Name: Rajeev Mahura
Date Of Birth: 15 Jan 1984
Address: New Delhi
Profession: DOEACC Trainer
DOEACC Center: DOEACC DELHI
Mobile No: 0

Re: Leap Year

Unread postby manojthesingham » Tue Sep 01, 2009 6:25 am

/*
Is 1100 is leap year or not ==> 1100 is not leap year
Earth Revolves around the Sun at 365.26 days
that 0.26 days are compensated as leap years
*/
#include<stdio.h>
#include<conio.h>

typedef enum{false=0,true=1}boolean;
boolean leap_year(int x)
{
if((x%400)==0)
return true;
if((x%100)==0)
return false;
if((x%4)==0)
return true;
return false;
}
int main(int argc,char **argv)
{
int x;
printf("Enter the year to check whther it is leap year or not : ");
scanf("%d",&x);
printf("%s",leap_year(x)?"LEAP Year":"Not A LEAP Year");
getch();
return 0;
}
If world is running, then I am idle..
If I am idle, then the world is running
User avatar
manojthesingham
 
Posts: 15
Joined: Tue Sep 01, 2009 5:39 am
Location: Coimbatore,Tamilnadu
Full Name: manoj
Date Of Birth: 31 Jul 1989
Address: Coimbatore18Tamilnadu
Mobile No: 0


Return to C-Language

Who is online

Users browsing this forum: No registered users and 1 guest

cron