Write a program to print the number of leap years in the given list of years.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int isLeapYear(int year){
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0){
return 1;
}
}
else{
return 1;
}
}
return 0;
}
int main(){
int n,i,year;
printf("Enter n: ");
scanf("%d",&n);
for(i=0;i<n;i++){
printf("Enter year %d: ",(i+1));
scanf("%d",&year);
if(isLeapYear(year)==1){
printf("Year is leap\n");
}else{
printf("Year is NOT leap\n");
}
}
getchar();
getchar();
return 0;
}
Comments
Leave a comment