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: <916@dcsc.dla.mil> Date: 28 Sep 90 15:47:15 GMT References: <9464@uhccux.uhcc.Hawaii.Edu> <24700010@sunc1> Reply-To: cze2529@dcsc.dla.mil.UUCP (Dave Gaulden) Organization: Defense Construction Supply Center, Columbus Lines: 36 In article <24700010@sunc1> mccaugh@sunc1.cs.uiuc.edu writes: > > Ordinarily, a leap-year is a multiple of four, so thst -- given leap-year y -- > (y%4 == 0) ought to indicate if y designates a leap-year. In article <9464@uhccux.uhcc.Hawaii.Edu> bush@uhccux.uhcc.Hawaii.Edu (Anthony Bush) writes: >date in 1945 so and so happened.. The trouble I am having is figuring >out the code in C++ in which it can figure out if the current year >is a leap year or not. Any help is appreciated. The following is a standard leapyear algorithm function if it is any help. main() { blah...blah.... if (month > 2) days += leapyear(year); } int leapyear(int year) /* standard leapyear algorithm */ { if (year % 4 == 0 && year % 100 != 0 !! year % 400 == 0) return 1; else 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