could somebody tell me what i'm doing wrong? i missed a class due to illness. my code is at the bottom
----------------------------------------------------------------------------------
Library functions allowed: printf, scanf
Write a program that will compute and display the date of Easter Sunday
for a given year entered by the user.
Your program begins by displaying the following on the screen:
This program calculates the Easter Sunday for a given year.
Please type a year between 500 and 4000 inclusive. (0 to quit)
The user will type a year, such as 1997. Your program will get the data
typed by the user, and save it in the variable called YEAR.
If the user has typed 0, then your program stops.
If the user has typed an invalid year, display the message:
The year is not valid.
Then the program returns to the beginning again.
If the user has typed a valid year, then call the calculatex function,
which will calculate the value of x. The main function must NOT do any
calculation using the formulas.
The formula for calculating the Easter Sunday date is:
X = 22 + A + B, where
A = remainder of ((19 x C) + 24) / 30
B = remainder of (( 2 x D) + (4 x E) + (6 x A) + 5) / 7
C = remainder of YEAR / 19
D = remainder of YEAR / 4
E = remainder of YEAR / 7
The calculatex function will return the value of x to the main function.
The main function will save the value of x in a variable called "dayx".
The main function then checks the value of dayx as follows:
If dayx is 31 or less, then Easter Sunday is in March, on dayx. For
example, if dayx = 11, then Easter Sunday is on March 11.
If the dayx is greater than 31, Easter will be in April. First subtract 31
from dayx. For example, if dayx = 33, subtract 31 from dayx, and dayx
becomes 2. Easter Sunday will be on April 2.
Your program should display the result as follows:
Easter Sunday of ... is on ....
For example, if you run your program and you type 1997, your program
should display:
Easter Sunday of 1997 is on March 30.
After displaying the Easter Sunday date, the program returns to the
beginning again.
Check your program with the following years, and other conditions.
Year Easter Sunday
1997 March 30
500 April 15
4000 April 1
The following gives you some hints on how your program may look like.
The ... are missing parts for you to fill in to complete the program.
The ... can be one or more lines of C statements.
#include <stdio.h>
... calculatex (...); /* function prototype */
int main (void)
{
int dayx;
...
dayx = calculatex (YEAR); /* call the calculatex function */
if (dayx > 31)
{
...
}
else
{
...
}
...
}
... calculatex (...) /* function definition */
{
int x;
...
return x;
}
---------------------------------------------------------------------------------
#include <stdio.h>
int calculatex(int y, int x);
int main(void)
{
int dayx, year;
do
{
do
{
printf("this program calculates the easter sunday for a given year./n");
printf("Please type a year between 500 and 4000 inclusive. (0 to quit./n");
scanf("%d", &year):
if(year==0)
{
return0;
}
if(year<500||year>4000)
{
printf("Invalid number./n");
}
}while(year<500||year>4000);
dayx=calculatex(year);
if(dayx>31)
{
dayx=31-dayx;
printf("Easter Sunday of %d is on April %d.\n", year, dayx);
}
else
{
printf("Easter Sunday of %d is on March %d.\n", year, dayx);
}
}while(1);
}
int calculatex(int y, int x)
{
int a, b, c, d, e, x;
c=year%19;
d=year%4;
e=year%7;
b=((2*d)+(4*e)+(6*a)+5)%7;
a=((19*c)+24)%30;
x=22+a+b;
return x;
}