Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!dsac.dla.mil!dcsc.dla.mil!cze2529 From: cze2529@dcsc.dla.mil (Dave Gaulden) Newsgroups: comp.lang.c Subject: Re: Leap Year Checker. Keywords: leapyear leap-year Message-ID: <917@dcsc.dla.mil> Date: 28 Sep 90 16:08:41 GMT References: <9464@uhccux.uhcc.Hawaii.Edu> <24700010@sunc1> <916@dcsc.dla.mil> Reply-To: cze2529@dcsc.dla.mil.UUCP (Dave Gaulden) Organization: Defense Construction Supply Center, Columbus Lines: 27 >main() >{ > blah...blah.... > > if (month > 2) > days += leapyear(year); > >} **** Sorry, there was a typo of one of the operators. **** int leapyear(int year) /* standard leapyear algorithm */ { if (year % 4 == 0 && year % 100 != 0 !! year % 400 == 0) return 1; ^^ else /* should be || above */ return 0; } Uses the return value to add the day if true. -- "Man who says, 'It cannot be done', should not interrupt man who is doing it." Dave Gaulden cze2529@dcsc.dla.mil