‘C’ program to check given year is leap year or not.

C File =>


/* Write a ‘C’ program to check whether the given year is leap year or not. */

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

      printf("Enter year: ");
      scanf("%d",&year);
 
      if(year % 4 == 0)
     {
          //Nested if else
        if( year % 100 == 0)
        {
            if ( year % 400 == 0)
                printf("\n%d is a Leap Year", year);
            else
                printf("\n%d is not a Leap Year", year);
          }
          else
               printf("\n%d is a Leap Year", year );
        }
        else
               printf("\n%d is not a Leap Year", year);
 
        return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.