C Program To Check Leap Year

C Program to check leap year

C Program to check leap year is a common program in c language which is mostly asked in practicals and exams, c programming is just perfect to make this program, in this particular program to check if a year is leap year or not we are given a year by the user and we have to check it that, it is a leap year or not. A leap year comes once after 4 years, means in four years there is just one leap year. We will make a program in which user will enter a year and we will find if it is a leap year or not.

Description of C Program to check leap year

In this program we will take a integer type variable, 'year' and then ask the user, to insert a year, and will store that in variable 'year', then using if statement we will check if 'year % 400 = = 0' then we will print the year is leap year then, use else if statement to check 'year%100= =0', if condition found true then print 'year is not leap year' for it again use if else statement to check if 'year%4= =0' then print 'this is a leap year', then use else statement and print 'year is not prime'.

C Program to check leap year

#include <stdio.h>
 
int main()
{
  int year;
 
  printf("Enter a year to check if it is a leap year\n");
  scanf("%d", &year);
 
  if ( year%400 == 0)
    printf("%d is a leap year.\n", year);
  else if ( year%100 == 0)
    printf("%d is not a leap year.\n", year);
  else if ( year%4 == 0 )
    printf("%d is a leap year.\n", year);
  else
    printf("%d is not a leap year.\n", year);  
 
  return 0;
}

Output


This is all how you can create a C program to check leap year simply, if face any problem in this program you are free to comment and ask your problems.
Previous
Next Post »