![]() |
|
#1
|
|||
|
|||
leap yearcan anyone suggest a formula to use when calculating the next leap year after a user inputs a year which is not a leap year and you want to show the next leap year.
i can not use any loops in this formula. thanks |
|||
|
#2
|
|||
|
|||
|
Note that leap years are equally divisible by 4. Hence there is no remainder. You'll also notice a sequence forming with the remainders when you divide other years by 4. For instance:
2000/4 = 500 remainder 0 2001/4 = 500 remainder 1 2002/4 = 500 remainder 2 2003/4 = 500 remainder 3 2004/4 = 501 remainder 0 2005/4 = 501 remainder 1 2006/4 = 501 remainder 2 2007/4 = 501 remainder 3 The remainder sequence repeats itself. You can then use this recurring sequence within an if/else structure and use the modulus operator to create the condition. For example: CPP / C++ / C Code:
Apologies for the syntax it's been a while since I've touched C++ or even did any programming. Hope this helps :-) Andrew Lai Quote:
|
Recent GIDBlog
Problems with the Navy (Officers) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Looking for Email Hosting, price per year. | JdS | Member Announcements, Advertisements & Offers | 12 | 29-Feb-2004 20:44 |
| Quote of the Year | BobbyDouglas | Open Discussion Forum | 2 | 14-Sep-2003 13:10 |
| Unlimited storage space/unlimited bandwidth with free domain only $99 per year | whssn | Web Hosting Advertisements & Offers | 2 | 09-Sep-2003 03:46 |
| 1st msg of year - Check it out | jrobbio | Websites Reviewed Forum | 9 | 15-Feb-2003 19:21 |
| Happy New Year | nniehoff | Open Discussion Forum | 0 | 02-Jan-2002 15:24 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The