diff --git a/Fiind_leap_year.c b/Fiind_leap_year.c new file mode 100644 index 0000000..a1222fa --- /dev/null +++ b/Fiind_leap_year.c @@ -0,0 +1,29 @@ +/*C program to print all leap years from 1 to N.*/ + +#include + +//function to check leap year +int checkLeapYear(int year) +{ + if( (year % 400==0)||(year%4==0 && year%100!=0) ) + return 1; + else + return 0; +} + +int main() +{ + int i,n; + + printf("Enter the value of N: "); + scanf("%d",&n); + + printf("Leap years from 1 to %d:\n",n); + for(i=1;i<=n;i++) + { + if(checkLeapYear(i)) + printf("%d\t",i); + } + + return 0; +}