ccplusplus.com
Learn C, C++ Concepts
Saturday, October 1, 2011
c program to check year is leap year
/*********************************************************************** * File : check-leap-year.c * Author : Saurabh Gupta * Desc : determine whether a year is leap year or not using conditional operators * c program to check year is leap year * leap year check in c * Source : http://saurabhgupta0527.blogspot.com/p/c.html * Created : PM 02:50 01 October 2011 * Note : ************************************************************************/ #include<stdio.h> int main() { int year; printf("ENTER YEAR ????\n"); scanf("%d",&year); year%100==0?(year %400==0?printf("leap Year") :printf("Not a Leap Year")):(year%4==0? printf("Leap Year"):printf("Not a leap Year")); printf ("\n"); return 0; } /* * OUTPUT * [sgupta@rhel55x86 c]$ gcc check-leap-year.c -o check-leap-year [sgupta@rhel55x86 c]$ ./check-leap-year ENTER YEAR ???? 2011 Not a leap Year [sgupta@rhel55x86 c]$ */
See also
Other popular tricky C Sample Codes and language Concept
.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment