Discussion Forums

New User? Please read instructions!

Need C program to find leap year  

  RSS

prakash
Eminent Member
Joined: 5 months  ago
Posts: 20
26/01/2017 10:31 am  

I need C program to find leap year. Kindly help. I have below details to write the C program logic.

Leap year is a year which has 366 days. Leap year occurs once every 4 years.

How to find whether a year is leap year or not using a C program?

* A year which can be exactly divisable by 4 except century years is called leap year.

* Century year means the year which ends with 00. Century year also can be a leap year if it is exactly divisable by 400.


ReplyQuote
prakash
Eminent Member
Joined: 5 months  ago
Posts: 20
30/01/2017 9:13 am  

Hi, I used below C program to find whether a year is leap year or not. It's working fine.

#include <stdio.h>

int main()

{

  int year;

  printf("\nPlease enter a year to check whether it is a leap year or not");

  scanf("%d", &year);

 

  if ( year%400 == 0)

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

  else if ( year%100 == 0)

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

  else if ( year%4 == 0 )

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

  else

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

  return 0;

}

Edited: 5 months  ago

ReplyQuote
  
Working

Please Login or Register

Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Share this website !!!
Facebook Twitter Linkedin

Close
We Support JALLIKATTU !!!
We Support JALLIKATTU!
By Fresh2Refresh.com
Show Your Support as well. Thanks!