answersLogoWhite

0


Best Answer

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

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

#include <stdio.h>

#include<conio.h>

void main()

{

int year;

clrscr();

printf("Enter the year which is to be checked for being leap or not");

scanf("%d",&year);

if (year%4==0 && (year%100!=0 year%400==0))

{

printf("leap year");

}

else

{

printf("not a leap year");

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

Use the following function to determine if a given year is a leap year or not:bool is_leap_year(int year) {

if (year%4) return false;

if (year%100) return true;

if (year%400) return false;

return true;

}

This works by a process of elimination, dealing with the most common cases first:

Years that are not divisible by 4 are not leap years.

Years that are divisible by 4 but not by 100 are leap years.

Years that are divisible by 100 but not by 400 are not leap years.

Years that are divisible by 400 are leap years.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

The simplest code for leap year in Java is something like this:
public static boolean isLeapYear(int year) {

return ((year % 4 0);

}


But recommend to use the standard Java library to test for a leap year:

new GregorianCalendar().isLeapYear(year);

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to find the year is leap year or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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 to find the largest and smallest character in a word?

helicopter


How do you find out the size of all the data types in C program?

sizeof is your friend.


How do you write a c program to find the smallest word in a string?

what is if(!(str[i]==32))


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.

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&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int year; clrscr(); printf("Enter the Year that you want to check : "); scanf("%d", &amp;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",&amp;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&lt;stdio.h&gt; #include&lt;conio.h&gt; int main() { int year, decided; printf("Enter the Year"); scanf("%d"&amp;year); decided= 0; if (year%4!=0) decided= -1; /* ordinary year, eg 1901 */ if (!decided &amp;&amp; year%100!=0) decided= 1; /* leap year, eg 1904 */ if (!decided &amp;&amp; year%400!=0) decided= -1; /* ordinary year, eg 1900 */ if (!decided) decided= 1; /* leap year, eg 2000 */ if (decided&lt;0) printf("Year is not Leap Year"); else printf ("Leap Year"); return 0; } it can can solve by this Easy method #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int year, lyear; printf("Enter the year = "); scanf("%d",&amp;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---&gt; 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