Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not.

#include<stdio.h>
int main()
   {
     Int   Y;
     printf( "Enter a year: " );
     scanf( "%d" ,&Y);
     if(Y%4==0 && Y%100!=0)
        printf( "\nLeap Year" );
     else if(Y%400==0)
        printf( "\nLeap Year" );
     else
         printf( "\nNot Leap Year" );
     return  0;
    }

6 comments:

  1. is it need to write ( else if(Y%400==0)) ?\

    ReplyDelete
    Replies
    1. Yes... That s the required conditions ....for example yr 1700 is not a leap year... though it is divided by 4 as well as 100.... Bt not divided by 400

      Delete
  2. this needs only y%4==0 .you make it complicated

    ReplyDelete
    Replies
    1. No bro....that is the required conditions....refer any book

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. complicated....would work the same at year%4==0

    ReplyDelete