/*********************************************
/
/ date-of-easter.c
/
/ A program to calculate the date of Easter
/ (Catholic and Protestant) using the method
/ of Spencer Jones - in his book General
/ Astronomy - as referenced in Astronomical
/ Algorithms - Jean Meeus - published by
/ Willmann-Bell, Inc., 1991.
/ ISBN 0-943396-35-2
/
/ May, 2014
/
/*********************************************/
#include "stdio.h"
#include "string.h"
int main(int argc, char* argv[])
{
int x; /* in what year do we want to calculate Easter? */
sscanf(argv[1],"%i",&x);
int a = (x % 19);
int b = (x / 100);
int c = (x % 100);
int d = (b / 4);
int e = (b % 4);
int f = ((b + 8) / 25);
int g = ((b - f + 1) / 3);
int h = ((19*a + b - d - g + 15) % 30);
int i = (c / 4);
int k = (c % 4);
int l = ((32 + 2*e + 2*i - h - k) % 7);
int m = ((a + 11*h + 22*l) / 451);
int n = ((h + l - 7*m + 114) / 31);
int p = ((h + l - 7*m + 114) % 31);
int year = x;
char month[6];
if (n == 3)
{
strcpy(month, "March");
}
if (n == 4)
{
strcpy(month, "April");
}
int day = p + 1;
printf ("In the year %d, Easter falls on %s %d\n", year, month, day);
return (0);
}
Like this:
Like Loading...