Write a C program to check Leap year or Not

Write a C program to check Leap year or Not

Program:

#include <stdio.h>
int main(){
int year;
printf(“Enter a year :”);
scanf(“%d”,&year);
if(((year%400==0 )||(year%100!=0))&&(year%4==0))
printf(“%d is a leap year.\n”,year);
else
printf(“%d is not a leap year.\n”,year);
return 0;
}

Output 1:

Enter a year: 1997
1997 is not a leap year.

Output 2:

Enter a year: 2004
2004 is a leap year

 

No Comments

Post a Reply