| Current Path : /var/www/html/bibhas.ghoshal/ITP_2019/lab/ |
| Current File : /var/www/html/bibhas.ghoshal/ITP_2019/lab/prog10.c |
#include<stdio.h>
int main(void)
{
short year, years_left;
printf("Enter year for leap year check: ");
scanf("%hd", &year);
if (year < 0) {
printf("Invalid year\n");
return 1;
}
if (year % 4 == 0) /*No parentheses required*/
printf("Year %hd is a leap year. \n"
"Next leap year is after 4 years \n",year);
else {
years_left = 4 - year % 4; /*No parentheses required */
printf("Year %hd is not a leap year. \n"
"Next leap year is %hd. \n", year, year + years_left);
}
return 0;
}