Thread: Easter Sunday

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    23

    Easter Sunday

    Hi,

    I'm tasked with creating a program that displays the date of Easter Sunday, and this is what I have been able to do far:

    Code:
    #include <stdio.h>
    
    int year, c, d, e, a, b, result, day, month;
    
    int main() {
        year = 2013;
        c = year % 19;
        d = year % 4;
        e = year % 7;
        a = (19 * c + 24) % 30;
        b = (2 * d + 4 * e + 6 * a + 5) % 7;
        result = 22 + a + b;
        day = result % 30 + ?; // ???
        month = 3 + ?; // ???
        printf("Easter Sunday in year %d is day %d of month %d\n", year, day, month);
    }
    What I'm stuck on is displaying the day and month correctly. Apparently we have to add a "magic quantity".

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Easter Sunday is celebrated on the Sunday following the paschal full moon: a full moon on or following the spring equinox. The church uses some approximations to make the calculation uniform: the lunar calendar begins with the new moon of the month of March and the full moon falls 14 days after. That should explain why Easter is on the 31 day this year for many denominations.

    The Eastern Orthodox church still uses the Julian calendar so the day is different for them.

    The church uses a few tables to help them calculate Easter for a given year, so saying "a magic quantity" really leaves me wondering what quantity you might be referring to, but I will link resources in the hope that you find or reckon what you need.

    Easter Dating Method - Calculate the Date of Easter Sunday
    How Is the Date of Easter Calculated? - How Do Christians Calculate the Date of Easter?

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    23
    From what we have been told in the class the magic quantity is the thing that yields a 0 for any March result and a 1 for any April result.

    We are then given the example: result/32

    Not exactly sure how to code this.

  4. #4
    Registered User
    Join Date
    Sep 2012
    Posts
    23
    Here is my latest code:
    I seem to have sorted out the months. Cant seem to get Days to display correctly.

    Code:
    #include <stdio.h>
    
    int year, c, d, e, a, b, result, day, month;
    
    int main() {
        year = 2013;
        c = year % 19;
        d = year % 4;
        e = year % 7;
        a = (19 * c + 24) % 30;
        b = (2 * d + 4 * e + 6 * a + 5) % 7;
        result = 22 + a + b;
        day = result % 32 + 2;
        month = 3 + result / 31;
        printf("Easter Sunday in year %d is day %d of month %d\n", year, day, month);
    }

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    What algorithm are you using?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Having trouble with Easter Sunday program
    By Chinnie15 in forum C Programming
    Replies: 7
    Last Post: 09-29-2011, 02:32 PM
  2. Help with Easter Day Calculator
    By chrandbar in forum C Programming
    Replies: 10
    Last Post: 03-26-2009, 12:40 PM
  3. This browser demo probably owns you 9 ways from sunday
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 08-22-2004, 12:04 AM
  4. Sunday Smut
    By Fordy in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 07-21-2002, 09:22 PM
  5. Easter Day?
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 03-30-2002, 06:25 PM