1-A year is called leap year if it is divisible by 400
2-If year is not divisible by 400 as well as 100 but it is divisible by 4 then that year are also leap year.
To determine a year is leap year or not...
#include<stdio.h>
int main(){
int year;
printf("Enter any year: ");
scanf("%d",&year);
if(((year%4==0)&&(year%100!=0))||(year%400==0))
printf("%d is a leap year",year);
else
printf("%d is not a leap year",year);
return 0;
}
To find leap year in between a range of year....
#include<stdio.h>
int main(){
int year;
int min_year,max_year;
printf("Enter the lowest year: ");
scanf("%d",&min_year);
printf("Enter the heighest year: ");
scanf("%d",&max_year);
printf("Leap years in given range are: ");
for(year = min_year;year <= max_year; year++){
if(((year%4==0)&&(year%100!=0))||(year%400==0))
printf("%d ",year);
}
return 0;
}
2-If year is not divisible by 400 as well as 100 but it is divisible by 4 then that year are also leap year.
To determine a year is leap year or not...
#include<stdio.h>
int main(){
int year;
printf("Enter any year: ");
scanf("%d",&year);
if(((year%4==0)&&(year%100!=0))||(year%400==0))
printf("%d is a leap year",year);
else
printf("%d is not a leap year",year);
return 0;
}
To find leap year in between a range of year....
#include<stdio.h>
int main(){
int year;
int min_year,max_year;
printf("Enter the lowest year: ");
scanf("%d",&min_year);
printf("Enter the heighest year: ");
scanf("%d",&max_year);
printf("Leap years in given range are: ");
for(year = min_year;year <= max_year; year++){
if(((year%4==0)&&(year%100!=0))||(year%400==0))
printf("%d ",year);
}
return 0;
}