GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 19-Aug-2005, 00:19
prometheus prometheus is offline
New Member
 
Join Date: Aug 2005
Posts: 1
prometheus is on a distinguished road

Homework help


I 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  
Old 19-Aug-2005, 04:40
maprich maprich is offline
Member
 
Join Date: May 2005
Posts: 163
maprich has a spectacular aura aboutmaprich has a spectacular aura about
Quote:
Originally Posted by prometheus
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)!
Did your instructor give you the exact above explanation??
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  
Old 19-Aug-2005, 10:56
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,791
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by maprich
Did your instructor give you the exact above explanation??
Because how can anybody figure out what "e = Year remainder 7" means.

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:
int year = 2005;
int YearRemainderSeven;

YearRemainderSeven = year % 7;

Regards,

Dave
 
 

Recent GIDBlogUS Elections and the ?Voter?s Responsibility? by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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

All times are GMT -6. The time now is 06:05.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.