prev


Modular Division Operator

14. Leap year or not (26.6.2009)

/*
Program# 14
date : 25-12-2008
Leap Year or not
*/

#include <stdio.h>
main(){
int n,x;
printf("\nEnter a year : ");
scanf("%d",&n);
x=n%4; // year which is divisible by 4 is said to be a leap year except the centuries like 400, 1200, 1600, 2000 etc..
if(x==0)
printf("\n%d : Leap year\n",n);
else
printf("\n%d : Ordinary year\n",n);
}

output:
Enter a year : 2008
2008 : Leap year

next
blog comments powered by Disqus