**Definition of leap year:**

Rule 1: A year is called leap year if it is divisible by 400.

For example: 1600, 2000 etc leap year while 1500, 1700 are not leap year.

Rule 2: If year is not divisible by 400 as
well as 100 but it is divisible by 4 then that year are also leap year.

For example:
2004, 2008, 1012 are leap year.

**Leap year logic or Algorithm of leap year or Condition for leap year:**

IF year MODULER 400 IS 0

THEN
leap_year

ELSE IF year MODULER 100 IS 0

THEN
not_leap_year

ELSE IF year MODULER 4 IS 0

THEN
leap_year

ELSE

not_leap_year

Code 1:

1.

**C program to determine leap year**
2.

**C program to find leap year or not**
3.

**Leap year calculation in c**
#include<stdio.h>

int main(){

int year;

printf("Enter any year: ");

scanf("%d",&year);

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

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

else

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

return 0;

}

Sample output:

Enter any year: 2010

2010 is not a leap year

Code 2:

1.

**Write a program to find leap year in c**
2.

**How to find leap year in c code**
#include<stdio.h>

int main(){

int year;

int min_year,max_year;

printf("Enter the lowest year: ");

scanf("%d",&min_year);

printf("Enter
the heighest year: ");

scanf("%d",&max_year);

printf("Leap
years in given range are: ");

for(year = min_year;year <= max_year; year++){

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

printf("%d
",year);

}

return 0;

}

Sample output:

Enter the lowest year: 2000

Enter the highest year: 2011

Leap years in given range is:
2000 2004 2008

10. Write a c program to add two numbers without using addition operator.

11. Write a c program to subtract two numbers without using subtraction operator.

15. Write a c program to solve quadratic equation.

18. Write a c program which passes structure to function.

28. Write a c program which takes password from user.

29. Write a scanf function in c which accept sentence from user.

30. Write a scanf function in c which accept paragraph from user.

## 35 comments:

thanks a lot

please make a change of if statement

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

Great work :) thanks a lot.. my doubt got cleared ...

explain?

great job yarrrr

YOU CAN TRUNCATE THE MIDDLE PART NUM%100 BECAUSE THERE ARE SOME LEAP WHOSE MODULUS ARE EQUAL TO HUNDERED

why dont u write it as year%4==0

it means year divided by 4 leaves remainder 0..

is it correct?

can u help me do it without using if statement

write a c program swapping of to no with out using third variable & with out using addition & substracting?

thanks a lot ritesh

1500 and 1700 are leap years...

you mentioned that it is not a leap year...

From wiki: 1600 was a leap year, but 1700, 1800 and 1900 were not.

To understand concept of leap year I hope this link will help you: Concept of leap year

Exactly!!

Go though this link:

SWAP TWO VARIABLES WITHOUT USING THIRD USING C PROGRAM VARIABLE

i hav a doubt...anybody can clear tis pls??? is thr any need to divide a year by 100?? y r v using tat???

I hope this will helpful ..

1600, 2000 etc leap year while 1500, 1700 are not leap year.

// if we enter 1500

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

{

// according to this 1500 not a leap year..

}

-----------------------------------

if ( (year%4==0) || (year%400==0) )

{

// according to this 1500 a leap year..

}

very useful

thanx bud!

can you do same program without using any logical operator?

int main(){

int year;

printf("Enter any year: ");

scanf("%d",&year);

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

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

else

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

return 0;

}

..............................................................

I think it's a wrong code.

when I try 2200 it shows that the year isn't leap year.

...............................................................

I think the code will be,

int main(){

int year;

printf("Enter any year: ");

scanf("%d",&year);

if(year%4==0)

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

else

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

return 0;

}

..........................................................................

If I'm wrong , please explain......

my code is correct or incorrect???plz help me.

if any mistake plz tell me???

Write a program that a year you enterd is leap year or not

#include

void main()

{

int year;

printf("Enter the Year = ");

scanf("%d",&year);

if(year%4==0)

printf("Leap Year ");

else

printf("Not Leap Year");

}

my code is correct or incorrect???plz help me.

if any mistake plz tell me???

Write a program that a year you enterd is leap year or not

#include

void main()

{

int year;

printf("Enter the Year = ");

scanf("%d",&year);

if(year%4==0)

printf("Leap Year ");

else

printf("Not Leap Year");

}

good for practicing this sight guys

"C program to check leap year"

Question:

How do i tweak the output of this code:

~let say i type in 2012 and the output should be February 29, 2014 Wednesday is a leap year (same thing with the other leap year)

~ i type in 2013 and the output should be 2013 is not a leap year.

Thanks in advance.

what if we need to enter day-month-year as input

how we want to determine the day of the year?

for sample output

Enter date:25-12-2014

This is day 359 0f year 2014

Thanks for these code, Here I have explained the math to solve the programm. Like why we will not take the year divisible by 100.

Thanks a lot........!!!

Rana....Bangladesh

can anyone explain why we are using %100 n %400 ?

can anyone help? sometimes it went to wrong. when a year is possible to divisible by 400 along with 100 that time what would i do? like 2000, 1200, 1600,

#include

int review()//Function for review the calculation...

{

int year;

int i=400;

int d=100;

int m=4;

if(year%i==0){

printf("Your entered Year is divisble by %d",i);

}

else if(year%d==0)

{

printf("Your entered Year is divisble by : %d",d);

}

else if(year%m==0)

{

printf("Your entered year is divisble by%d",m);

}

else{

printf("May be there is a error in input:");

printf("Try again!");

}

return 1;

}

int main()

{

//check the year if it is leap year

int year;

while(year!=0){

printf("\nEnter a Year:\n");

scanf("%d",&year);

//}

if(year%400==0)//(if a year divisble by 400 then it is leap year.)

{

printf("This is leap year:%d",year);

}

else if(year%100==0)//(If a year is divisble by 100 then it is not a leap year)

{

printf("This year is not leap year:%d",year);

}

else if(year%4==0)//(If a year divisble by 4 then it is leap year....)

{

printf("This is leap year:%d",year);

}

else{

printf("This is not leap year. ");

}

printf("\nReview");

printf("\n________________________________________________\n");

review();

}

return 0;

}

I

I think this code is the exact solution for finding leap year::::::::::::: can you try this ????

else

{

printf(" %dThis is leap year:");

}

Here some condition............

#include

int main()

{

int year;

scanf("%d",&year);

if(year%4==0)

{

if(year%100==0)

{

if(year%400==0)

{

printf("%d This is leap year:",year);

}

else

{

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

}

}

else

{

printf(" %dThis is not leap year:",year);

}

}

else

{

printf(" %d This is not leap year:");

}

return 0;

}

#include

int main()

{

int year;

scanf("%d",&year);

if(year%4==0)

{

if(year%100==0)

{

if(year%400==0)

{

printf("%d This is leap year:",year);

}

else

{

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

}

}

else

{

printf(" %dThis is not leap year:",year);

}

}

else

{

printf(" %d This is not leap year:");

}

return 0;

}

Wrong because year%4==0 is not the necessary condition for any year to be a leap year.

Wrong because year%4==0 is not the necessary condition for any year to be a leap year.

Hi,

Help me with this program

How to get leap year using recursion..

Post a Comment