Adapted the mechanism showed here:
http://en.wikipedia.org/wiki/Computus#Meeus.2FJones.2FButcher_Gregorian_algorithmSave the text below as easter.c and, under Linux or Mac OS, compile like this: "gcc -DSTANDALONE -Wall -o easter easter.c"
It should also compile as a console program under Visual C++. I suppose.
Programmer types can use it as a library, by not defining STANDALONE.
"easter", on its own, prints this year's Easter. For other years, use "easter 2009", "easter 1993" etc.
#include <time.h>
#ifdef STANDALONE
#include <stdio.h>
#include <stdlib.h>
#endif
void easter(int year, int *month, int *day)
{
int a, b, c, d, e, f, g, h, i, k, l, m;
a = year % 19;
b = year / 100;
c = year % 100;
d = b / 4;
e = b % 4;
f = (b + 8) / 25;
g = (b - f + 1) / 3;
h = (19 * a + b - d - g + 15) % 30;
i = c / 4;
k = c % 4;
l = (32 + 2 * e + 2 * i - h - k) % 7;
m = (a + 11 * h + 22 * l) / 451;
*month = (h + l - 7 * m + 114) / 31;
*day = ((h + l - 7 * m + 114) % 31) + 1;
}
#ifdef STANDALONE
int main (int argc, char **argv)
{
int myyear, mymonth, myday;
time_t now;
struct tm localnow;
if (argc < 2)
{
time(&now);
localtime_r(&now, &localnow);
myyear = localnow.tm_year + 1900;
}
else
myyear = atoi(*(argv + 1));
easter(myyear, &mymonth, &myday);
printf("%d/%d/%d\n", myyear, mymonth, myday);
return 0;
}
#endif
EDIT: the above is in the public domain.