answersLogoWhite

0

Algorithm:

If the year is not divisible by 4 then it is not a leap year.

Else if the year is not divisible by 100 then it is a leap year.

Else if the year is not divisible by 400 then is not a leap year.

Else it is a leap year.

Implementation:

bool is_leap_year (unsigned year) {

if (year%4) return false;

if (year%100) return true;

if (year%400) return false;

return true;

}

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

What is the program in c to check whether a year is leap year or not in simple way?

If the year divides evenly by 4 it's a leap year. If it's a century year it has to divide evenly by 400. 2000 was a leap year. 2100 will not be a leap year.


C program to generate a list of leap years between 1900 -2000?

3900


Write a c program to find leep year through nested if?

// leap year by @bhi// #include<stdio.h> #include<conio.h> void main() { int year; clrscr(); printf("Enter the Year that you want to check : "); scanf("%d", &year); if(year % 400 == 0) printf("%d is a Leap Year.", year); else if(year % 100 == 0) printf("%d is not a Leap Year.", year); else if(year % 4 == 0) printf("%d is a Leap Year.", year); else printf("%d is not a Leap Year", year); printf("\nPress any key to Quit..."); getch(); }


C program was introduced in the year?

c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.


C program which takes a year as an argument and returns 1 if the year is a leap year or returns 0 if the year is not leap year use to display all the leap years between 2000 and 2500?

int isleap(int year) {return year % 4 0 && year % 400 != 0);}The rule is that years divisible by 4 are leap, except that century years not divisible by 400, such as 2100, are not leap. The question stated a range of 2000 to 2500, so the answer does not address non Gregorian calendars or the shift between Julian and Gregorian.


C program for leap year using conditional operator?

#include #include void main() { int y; clrscr(); print f ("enter a year"); scan f ("%d",&y) (y%100==0):((y%400==0)?print f("% d is leap year",y):print f("%d is not leap year",y):((y%4==0)? print f ("d is leap year",y): print f ("%d is leap year",y): print f ("%d is not leap year,y)); getch(); }


Program for sin series in c language?

find the program in c-pgms.blogspot.com


Leap year program in c?

LEAP YEAR:-if the year is divisible by 4 that year is leap year and the year is divisible by 100 which gives remainder 0 then that year is not a leap year....... #include<stdio.h> #include<conio.h> int main() { int year, decided; printf("Enter the Year"); scanf("%d"&year); decided= 0; if (year%4!=0) decided= -1; /* ordinary year, eg 1901 */ if (!decided && year%100!=0) decided= 1; /* leap year, eg 1904 */ if (!decided && year%400!=0) decided= -1; /* ordinary year, eg 1900 */ if (!decided) decided= 1; /* leap year, eg 2000 */ if (decided<0) printf("Year is not Leap Year"); else printf ("Leap Year"); return 0; } it can can solve by this Easy method #include<stdio.h> #include<conio.h> void main() { int year, lyear; printf("Enter the year = "); scanf("%d",&year); lyear=year%4; if(lyear==0) { printf("Leap year"); } else { printf("Not a Leap year"); } getch(); }


How do you write socket program in c?

For first find an example program.


C program to find area of a triangle?

find the area of abc a[2,3] c[6,0]


C program to find the mean median mode?

try this---> http://c-pgms.blogspot.com/2008/08/program-to-find-meanmedianand-mode_22.html


How do you program an ungrouped median?

find median of n observation in c program