answersLogoWhite

0


Best Answer

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();

}

User Avatar

Wiki User

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

Wiki User

15y ago

Below is a program; not completely bullet proof - allows negative years! #include <stdio.h> #define true 1

#define false 0 void main(int argc, char *args[])

{

int year; if(argc !=2)

{

printf("Usage:\n\n%s <year>\n",args[0]);

exit(0);

}

year = atoi(args[1]);

if (IsLeap(year))

printf("%d is a leap year.",year);

else

printf("%d is not a leap year.",year);

} int IsLeap(int year) {

int Result; if (year % 400 0)

{

Result = true;

}

else

{

Result = false;

}

}

}

return Result;

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Leap year program in c
Write your answer...
Submit
Still have questions?
magnify glass
imp
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


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.


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 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 to find the year is leap year or not?

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; }


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(); }


Write a program to check whether a given year is leap year or not using ternary operator?

leap yr = ((y%100!=0 &amp;&amp; yr %400==0)?1:(yr%4==0)?1:0; leap yr =1; printf ("leap yr"); else printf ("not leap yr");


How do you write a program in java to check a year leap year or not and display the proper message?

You can use a number of nested "if" commands. The rules are the following: If the year is a multiple of 400, it IS a leap year. Else, if the year is a multiple of 100, it's NOT a leap year. Else, if the year is a multiple of 4, it IS a leap year. Else it's NOT a leap year. In Java, to check for divisibility, you use the "%" operator, which gives you the remainder of a division. For example: if (year % 400 = 0) ... To show results on screen, you use: System.out.println(...)


Will the year 3080 be a leap year?

3080 will be a leap year.


Is 1776 a leap year?

1776 was a leap year


Is 2014 a leep year?

No. If the year number can be divided by four then it's a leap year. 2012=Leap year.