This is a C Program which computes the date of Easter Sunday. |
Here is the algorithm by Carl Friedrich Gauss :
Step 1 : Let Y be the year
Step 2 : Divide Y by 19 to get a remainder as A
Step 3 : Divide Y by 100 to get a quotient B and a remainder C
Step 4 : Divide B by 4 to get a quotient D and a remainder E
Step 5 : Divide (8*B+13) by 25 to get a quotient G
Step 6 : Divide (19*A+B-D-G+15) by 30 to get a remainder H
Step 7 : Divide C by 4 to get a quotient J and a remainder K
Step 8 : Divide (A+11*H) by 319 to get a quotient M
Step 9 : Divide (2*E+2*J-K-H+M+32) by 7 to get a remainder R
Step 10: Divide (H-M+R+90) by 25 to get a quotient N
Step 11: Divide (H-M+R+N+19) by 32 to get a remainder P
So for a given year Y Easter Sunday falls on day P and month N
Step 2 : Divide Y by 19 to get a remainder as A
Step 3 : Divide Y by 100 to get a quotient B and a remainder C
Step 4 : Divide B by 4 to get a quotient D and a remainder E
Step 5 : Divide (8*B+13) by 25 to get a quotient G
Step 6 : Divide (19*A+B-D-G+15) by 30 to get a remainder H
Step 7 : Divide C by 4 to get a quotient J and a remainder K
Step 8 : Divide (A+11*H) by 319 to get a quotient M
Step 9 : Divide (2*E+2*J-K-H+M+32) by 7 to get a remainder R
Step 10: Divide (H-M+R+90) by 25 to get a quotient N
Step 11: Divide (H-M+R+N+19) by 32 to get a remainder P
So for a given year Y Easter Sunday falls on day P and month N
PROGRAM :
#include <stdio.h>
#include <stdlib.h>
int main()
{
int y;
printf("Enter Year :\t");
scanf("%d",&y);
if(y <= 0)
printf("\nPlease enter a valid Year\n");
else
{
int a =y%19;
int b = y/100;
int c = y%100;
int d = b/4;
int e = b%4;
int g = (8*b+13)/25;
int h =(19*a+b-d-g+15)%30;
int j = c/4;
int k = c%4;
int m = (a+11*h)/319;
int r = (2*e+2*j-k-h+m+32)%7;
int n = (h-m+r+90)/25;
int p = (h-m+r+n+19)%32;
printf("\n\nEaster Sunday for year %d is ",y);
switch(n)
{
case 1:
printf("January %d\n" ,p);
break;
case 2:
printf("February %d\n" ,p);
break;
case 3:
printf("March %d\n" ,p);
break;
case 4:
printf("April %d\n" ,p);
break;
case 5:
printf("May %d\n" ,p);
break;
case 6:
printf("June %d\n" ,p);
break;
case 7:
printf("July %d\n" ,p);
break;
case 8:
printf("August %d\n" ,p);
break;
case 9:
printf("September %d\n" ,p);
break;
case 10:
printf("October %d\n" ,p);
break;
case 11:
printf("November %d\n" ,p);
break;
case 12:
printf("December %d\n" ,p);
break;
default:
printf("Invalid ,TRY AGAIN !!" );
}
}
return 0;
}OUTPUT :
| C Program for computing Easter Sunday |
| C Program for computing Easter Sunday |