Saturday, January 5, 2019

write a c program to find leap year or not, using nested if-else

Find leap year or not, using nested if-else 

#include<stdio.h>
#include<conio.h>
void main()
{
int year;
clrscr();
printf("\n Enter Year");
scanf("%d",&year);
if((year % 100) == 0)
{
  if((year % 400) == 0)
   {
    printf("\n Year %d is Leap ",year);
   }
  else
   {
    printf("\n Year %d is Not Leap ",year);
   }
}
else
{
  if((year % 4) == 0)
  {
   printf("\n Year %d is Leap ",year);
  }
  else
  {
   printf("\n Year %d is Not Leap ",year);
  }
}
getch();

}

0 comments:

Post a Comment