Users Online

· Guests Online: 141

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

46 C Program to Find if a given Year is a Leap Year

This C Program checks whether a given year is a leap year. When A year is divided by 4. If remainder becomes 0 then the year is called a leap year.
Here is source code of the C program to check a given year is leap year. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*
* C program to find whether a given year is leap year or not
*/
void main()
{
int year;

printf("Enter a year \n");
scanf("%d", &year);
if ((year % 400) == 0)
printf("%d is a leap year \n", year);
else if ((year % 100) == 0)
printf("%d is a not leap year \n", year);
else if ((year % 4) == 0)
printf("%d is a leap year \n", year);
else
printf("%d is not a leap year \n", year);
}

$ cc pgm47.c
$ a.out
Enter a year
2012
2012 is a leap year

$ a.out
Enter a year
2009
2009 is not a leap year

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.85 seconds
10,816,600 unique visits