Discussion Forums

New User? Please read instructions!

Need C program to find leap year  

  RSS

prakash
(@prakash)
Eminent Member
Joined:2 years  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
(@prakash)
Eminent Member
Joined:2 years  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;

}


deepshika1 liked
ReplyQuote
shashitimon
(@shashitimon)
New Member
Joined:1 year  ago
Posts: 1
15/11/2017 7:20 pm  

#include<stdio.h>

int main()

{

int year;

printf("Enter an year : ");

scanf("%d",&year);

if(year%4==0)

{

printf("Leap year");

}

else

{

printf("Not a leap year");

}

}


ReplyQuote
manoj
(@manoj)
New Member
Joined:12 months  ago
Posts: 2
24/12/2017 4:49 pm  

#include<studio.h>

#include<conio.h>

void main()

{

int n;

print("enter the  which to be leap year or not");

scanf("%d",&n);

if(n%4==0)

{

print("it's a leap year");

}

else

{

print("not a leap year");

}

getch();

}


ReplyQuote
neosphere
(@neosphere)
New Member
Joined:11 months  ago
Posts: 1
20/01/2018 7:20 am  

#include <stdio.h>

int main()
{
int year;

printf("Enter a year: ");
scanf("%d",&year);

if(year%4 == 0)
{
if( year%100 == 0)
{
// year is divisible by 400, hence the year is a leap year
if ( year%400 == 0)
printf("%d is a leap year.", year);
else
printf("%d is not a leap year.", year);
}
else
printf("%d is a leap year.", year );
}
else
printf("%d is not a leap year.", year);

return 0;
}

Output 1:

Enter a year: 1900
1900 is not a leap year.

 

Output 2:

Enter a year: 2012
2012 is a leap year.

neosphere.com.np


ReplyQuote
Share:

OTHER C PROGRAMS:

  1. C program for prime number
  2. C program for factorial
  3. C program for fibonacci series
  4. C program for palindrome
  5. C program for swapping 2 numbers with and without temp variables
  6. C program to find leap year
  7. C program to find armstrong number
  8. C program to find simple and compound interest
  9. C program to find largest of given 3 numbers
  10. C program to find smallest of given 3 numbers
  11. C program to convert lower case into upper case and vice versa
  12. C program to find sum and average of given 3 numbers
  13. C program to sum up all individual digits
  14. C program to reverse given number
  15. C program to reverse given string
  16. C program to find strong number
  17. C program to find square and cube of given number
  18. C program to print hello world without using semi colon
  19. C program to sort given names in alphabetical order
  20. C program to copy content of one file to another
  21. C program to sort given numbers in ascending order
  22. C program to sort given numbers in descending order
  23. C program to search given number in an array
  24. C program for recursive function
  25. C program for calculator application
  26. C program for bank application
  27. C program to check given number is perfect number or not
  28. C program to find array size
  29. C program to find whether given character vowel or not
  30. C program to check whether given number is positive or negative
  31. C program to find sum of n numbers
  32. C program to compare 2 numbers without if statement
  33. C program to generate random numbers
  34. C program to compare 2 arrays whether they are equal or not
  35. C program to print number from 1 to 500 without using any loop conditions
  36. C program to insert an element into an array
  37. C program to delete an element from an array
  38. C program to find hcf (gcd) and lcm
  39. C program to print diamond pattern
  40. C program to print pascal triangle
  41. C program to add two complex numbers
  42. C program for binary search
  43. C program for linear search
  44. C program for matrix addition
  45. C program for matrix multiplication
  46. C program for bubble sort
  47. C program for insertion sort
  48. C program for selection sort

Share this website !!!
Facebook Twitter Linkedin

  
Working

Please Login or Register