1 – C program for leap year, easy and simple code

C program for leap year

C program to check leap year : 

We know that there are 365 day in a year but it is wrong. in one year there are 365.25 days. Hence every 4 year we have one extra day.

We have to use simple mathematics logic to solve this problem.

If year is divided by 4 then it is leap year.

If year is divided by 4 and not by 100 then it is leap year.

If year in not divisible by 4 then it is not a leap year.

If year is divisible by 4 and 100 then it must be divisible by 400 otherwise it is not a leap year.

#include<stdio.h>
int main()
{
int year;

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

if(year % 4 == 0)
{
if( year % 100 == 0)
{
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 :

Enter year : 2006

2006 is not a leap year

PRACTICALS IN C PROGRAM

Programs to understand the basic data types and I/O.
Programs on Operators and Expressions.
Programs on decision statements.
Programs on looping.
Programs on arrays.
Programs on functions.
Programs on structures and unions.
Programs on pointers.
Programs on string manipulations.
Practice Programs
1 – C program for leap year, easy and simple code
2 – Best C program to find sum of all digits
3 – Best C program to check Palindrome Number
4 – Best C program to check prime number
5 – Best C program to print Fibonacci series
6 – Best C program to reverse a number
7 – Best C program to reverse an array
8 – Best C program to find average of array
9 – Best C program to find frequency of array element
10 – Best C program to sort array in ascending order
11 – Best C program to find factorial using recursion
12 – Best C program to find sum of all numbers in array
13 – Best C program to find largest element in array
14 – Best C program to swap two numbers without third variable
15 – C Program to check if a number is even or odd
16 – C program to find Simple interest
17 – Best C program to add two matrices
18 – Best C program to count vowels and consonants in a string
19 – Best C program to find LCM
20 – Best C program to find HCF
21 – Best C program to swap two numbers using pointers
22 – Best C program to add two numbers using pointers
23 – Best C program to print Multiplication Table
24 – Best C program to check Armstrong number
25 – Best C program to print half pyramid of star(*)
26 – Best C program to print half pyramid of numbers
27 – Best C program to print reverse half pyramid of star
28 – Best C program to print reverse half pyramid of number
More coming soon…

CHECKOUT OTHER RELATED TOPICS

CHECKOUT OTHER QUIZZES

We are aiming to explain all concepts of C in easiest terms as possible.
ITVoyagers-logo
ITVoyagers
Author

Leave a Comment