/*
Given a year (an integer number), say if it is a leap year.
A leap year is divisible by 4, but not by 100.
An exception are the years divisible by 400, which are leap years.
*/#include <stdio.h>int main(void){int leap=0;int year;printf("Insert an year: ");scanf("%d",&year);/* First solution: base on a support varible leap */if( year%4==0)/* divisible by 4 */
leap=1;if( year%100==0)/* but not by 100 */
leap=0;if( year%400==0)/* but year divisible by 400 are leap years */
leap=1;if( leap==1){printf("%d is a leap year\n", year);}else{printf("%d is not a leap year\n", year);}/* Second solution: using a boolean expression */if((year%4==0&& year%100!=0)|| year%400==0){printf("%d is a leap year\n", year);}else{printf("%d is not a leap year\n", year);}return0;}

If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it