Leap Year Program in C using Nested-If-Block

  • Nested-If block is nothing but defining If-block inside another If-block.
  • This Program explains how to implements Leap year program using Nested-if-block.

#include<stdio.h>
void main()
{
int y ;
printf(“Enter year : “);
scanf(“%d”, &y);
if(y%100==0)
{
if(y%400==0)
printf(“Leap year”);
else
printf(“Not leap year”);
}
else
{
if(y%4==0)
printf(“Leap year”);
else
printf(“Not leap year”);
}
}

Share this