Hello,
I am brand new to programming and am having a lot of trouble in the class I had to take this semester. I'm a Biology major, so obviously have no idea when it comes to programming (but this class is a requirement, for some reason). Anyway, I have barely been keeping up with the concepts, and am still getting very confused. Some programs I have written up just fine (like a calculator), but this one I am having a lot of trouble with.
Here are the exact words from the HW:
- Have the user enter a year between 1982 and 2048. You can compute the date for any Easter Sunday using the following formulas (all values are integers):
- “a” is a year % 19
- “b” is year % 4
- “c” is year % 7
- “d” is (19 * a + 24) % 30
- “e” is (2 * b + 4 * c + 6 * d + 5) % 7
Easter Sunday is March (22 + d + e)
Write a program that inputs the year and outputs the date (month and day) of Easter Sunday for that year. Print the input as part of the output. For example:
Enter the year (for example, 1999):
1985
Easter is Sunday, the 7, in 1985
Here is what I have so far:
Now, I realize it isn't complete (I'm not sure how to differentiate between March and April, and not sure how to get the output into the input), but from what I am able to understand, it should at least be working and giving me 'March - day'. But, I keep getting two warnings. These warnings are '25: format ^ayear^a expects type ^aint *^a, but argument 2 has type ^aint^a', and '16: ^ayear^a is used uninitialized in this function'.Code:#include <stdio.h> int main() { printf("name here" \n"); int year; int a ; int b ; int c ; int d ; int e ; int easter_sunday ; a = year % 19 ; b = year % 4 ; c = year % 7 ; d = (19 * a + 24) %30 ; e = (2 * b + 4 * c + 6 * d + 5) % 7 ; easter_sunday = (22 + d + e) ; /* Get year from user*/ printf ("Enter year between 1982 and 2048: ") ; scanf ("%d", year) ; printf ("\n Easter Sunday is March %d", easter_sunday) ; return 0; }
I'm sorry if any of this doesn't make any sense. As I said, I am having a lot of trouble understanding this as it's so unlike anything I've ever done before. I think I'm sort of on the right track, but something isn't quite working right.
Any help would be very much appreciated!
Thank you!