Program Description:
Leap year is a year occurring in every 4 years having 366 days which has 29 February as an interplanetary day. In this program we are going to check whether a year is a leap year or not. Non century years if gets divided by 4 completely leaving 0 as remainder, then it is a leap year. In case of century years (years which get completely divided by 100), if they are totally divided by 400, then they are leap year. In this program we are going to use if-else conditions.
\
Source code:
// C program to check whether a year is leap year or not!#include<stdio.h>
int main()
{
int year,i=1;
while(i==1)
{
printf("\nEnter the year you want to check:");
scanf("%d",&year);
if((year%4==0) && (year%100!=0 ))
printf("%d is a leap year\n",year);
else if((year%4==0) && (year%100==0 ) && (year%400==0))
printf("%d is a leap year\n",year);
else
printf("%d is not a leap year\n",year);
printf("Do you want to check another year?(0/1)");
scanf("%d",&i);
if(i!=1)
break;
}
printf("THANK YOU");
}
Output:
If you have any query feel free to contact us😊😊
0 Comments