![]() |
|
#1
|
|||
|
|||
Homework helpI have the following peice of HW to complete, and it seems easy. but for some reason, no matter what coding I try I get incorrect answers...can someone give me the coding they might use to solve this problem? I am supposed to code it in C
" Write a program to compute and print the day of Easter Sunday in 2005. The output should be in the form: Month m, day n. Where m is the month number (3 for March, 4 for April), and n is the day in the month. The date for Easter Sunday is March(22 + a + b), where a = (19c + 24) remainder 30 b = (2d + 4e + 6a + 5) remainder 7 c = year remainder 19 d = year remainder 4 e = year remainder 7 If (22 + a + b) is greater than 31, the date is in April. You will need to do a division and remainder to correct for this. Make sure that your program also works for other years - 1991 (31st March), 1997 (30th March) and 2018 (1st April)! " |
|
#2
|
|||
|
|||
|
Quote:
Because how can anybody figure out what "e = Year remainder 7" means. If 7 is the remainder then what is the divider??? That explanation is simply incorrect and misleading. Ok I found the correct explanation from wikipedia. Seems that you are supposed to implement Gauss's algorithm of calculating the date of Easter. (in gregorian calender) So the above "e = Year remainder 7" should be "e = Year mod 7". The latter makes sense but the former doesn't. Besides the wikipedia presentation of the algorithm is also much better and more informative. It also mentions 2 exceptions to the method of which your instructors explanation doesn't mention anything. But that's alright I suppose since it only makes this homework simpler. And as we know homeworks are not supposed to be realistic they are just something supposed to keep you busy. Quick plunge to modular arithmetic in here |
|
#3
|
|||
|
|||
|
Quote:
For positive integers, the expression "year modulo 7" has the same meaning as "the remainder after dividing the year by 7". People (instructors) who don't want to introduce the mathematical concept, definition, and notation of equivalence classes might use the expression "year remainder 7" to mean "the remainder after dividing the year by seven". For positive integers, the value of this expression can be calculated in C by the '%' operator. The original author of the C language called the '%' operator the "modulus operator". CPP / C++ / C Code:
Regards, Dave |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| read file into array | Requoter | C++ Forum | 9 | 28-Mar-2005 23:39 |
| C if/else statement problem | JYGUTI | C Programming Language | 1 | 28-Mar-2005 06:58 |
| C++ Homework Due Tomorrow. Help! | snatbot | C++ Forum | 3 | 02-Mar-2005 16:34 |
| help!!!!!!!! C++ homework | newbie | C++ Forum | 2 | 20-Jan-2004 10:41 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The