/*A
leap year (also known as an
intercalary year or a
bissextile year) is a year containing one additional day (or, in the case of
lunisolar calendars, a month) added to keep the
calendar year synchronized with the
astronomical or
seasonal year.
[1] Because seasons and astronomical events do not repeat in a
whole number of days, calendars that have the same number of days in each year, drift over time with respect to the event that the year is supposed to track. By inserting (also called
intercalating) an additional day or month into the year, the drift can be corrected. A year that is not a leap year is called a
common year.
Algorithm
if (year is not exactly divisible by 4) then (it is a common year)
else if (year is not exactly divisible by 100) then (it is a leap year)
else if (year is not exactly divisible by 400) then (it is a common year)
else (it is a leap year) */
Program
#include <stdio.h>
void main()
{
int year;
printf("Enter a year to check if it is a leap 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 not a 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);
}
Output
Enter a year to check if it is a leap year
2012
2012 is a leap year.
Hey thank you for providing this program. I have related one visit leap year program
ReplyDeleteAccording to the 2012 report, Global Trends 2030: Alternative Worlds, published the US National Intelligence Council, four technology arenas will shape global economic, social and military developments by 2030. They are information technologies, automation and manufacturing technologies, resource technologies, and health technologies. Information technologies Three technological developments with an IT focus have the power to change the way we will live, do business and protect ourselves before 2030. programming assignments
ReplyDeleteThanks for the info. And a response from you. car dealers hips san jose بازی انفجار
ReplyDeleteWhen I firstly commented I clicked the “Notify me when new comments are added” checkbox and after this every time a comments is newly added I recieve four e-mail with only one statement. Could there be by any means you may remove me from that service plan? Many thanks! buy shrooms
ReplyDeleteWhat a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. best office chair for programmers
ReplyDelete