Question

In C Programming Easter Sunday is the first Sunday after the first full moon of spring....

In C Programming

Easter Sunday is the first Sunday after the first full moon of spring. To compute the date, you can use this algorithm, invented by the mathematician Carl Friedrich Gauss in 1800:
        1. Let y be the year (such as 1800 or 2001)
        2. Divide y by 19 and call the remainder a. Ignore the quotient.
        3. Divide y by 100 to get a quotient b and a remainder c.
        4. Divide b by 4 to get a quotient d and a remainder e.
        5. Divide 8 * b + 13 by 25 to get a quotient g. Ignore the remainder.
        6. Divide 19 * a + b - d - g + 15 by 30 to get a remainder h. Ignore the quotient.
        7. Divide c by 4 to get a quotient j and a remainder k.
        8. Divide a + 11 * h by 319 to get a quotient m. Ignore the remainder.
        9. Divide 2 * e + 2 * j - k - h + m + 32 by 7 to get a remainder r. Ignore the quotient.
        10. Divide h - m + r + 90 by 25 to get a quotient n. Ignore the remainder.
        11. Divide h - m + r + n + 19 by 32 to get a remainder p. Ignore the quotient.
The Easter faqs on day p of month n. For example, if y is 2001:
a = 6
b = 20, c = 1
d = 5, e = 0
g = 6
h = 18
j= 0, k = 1
m = 0
r = 6
n = 4
p = 15
Therefore, in 2001, Easter Sunday fell on April 15. Write a program that prompts the user for a year and prints out the month and day of Easter Sunday.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the C code below.

******************************************************************************************************************************

#include <stdio.h>
int main()
{
int y;
printf("Enter the year : ");
scanf("%d",&y);
int a = y%19; //Divide y by 19 and call the remainder a. Ignore the quotient.
int b = y/100; //Divide y by 100 to get a quotient b .
int c = y % 100; //Divide y by 100 to get a remainder c.
int d = b / 4; //Divide b by 4 to get a quotient d.
int e = b % 4; //Divide b by 4 to get a remainder e.
int g = (8*b + 13) / 25; // Divide 8 * b + 13 by 25 to get a quotient g. Ignore the remainder.
int h = (19 *a + b - d-g +15) % 30 ; //Divide 19 * a + b - d - g + 15 by 30 to get a remainder h. Ignore the quotient.
int j = c /4 ; //Divide c by 4 to get a quotient j.
int k = c % 4; //Divide c by 4 to get a remainder k.
int m = (a + 11 * h) / 319 ; // Divide a + 11 * h by 319 to get a quotient m. Ignore the remainder.
int r = ( 2 * e + 2 *j - k - h + m + 32) % 7;//Divide 2 * e + 2 * j - k - h + m + 32 by 7 to get a remainder r. Ignore the quotient.
int n = (h - m + r + 90) / 25;//Divide h - m + r + 90 by 25 to get a quotient n. Ignore the remainder.
int p = (h - m + r + n + 19) % 32;//Divide h - m + r + n + 19 by 32 to get a remainder p. Ignore the quotient.
switch(n) { //switch function to find the month
       case 1 : printf("In %d , Easter Sunday fell on January %d",y,p); break;
       case 2 : printf("In %d , Easter Sunday fell on February %d",y,p); break;
       case 3 : printf("In %d , Easter Sunday fell on March %d",y,p); break;
       case 4 : printf("In %d , Easter Sunday fell on April %d",y,p);break;
       case 5 : printf("In %d , Easter Sunday fell on May %d",y,p); break;
       case 6 : printf("In %d , Easter Sunday fell on June %d",y,p); break;
       case 7 : printf("In %d , Easter Sunday fell on July %d",y,p); break;
       case 8 :printf("In %d , Easter Sunday fell on August %d",y,p); break;
       case 9 : printf("In %d , Easter Sunday fell on September %d",y,p); break;
       case 10 : printf("In %d , Easter Sunday fell on October %d",y,p); break;
       case 11 : printf("In %d , Easter Sunday fell on November %d",y,p); break;
       case 12 : printf("In %d , Easter Sunday fell on December %d",y,p); break;
       default : printf("Invalid month.");
   }   
return 0;
}

***************************************************************************************************************************************

Please refer to the screenshot for the code below

*****************************************************************************************************************************************

**********************************************************************************************************************************

output screenshot

************************************************************************************************************************************

Add a comment
Know the answer?
Add Answer to:
In C Programming Easter Sunday is the first Sunday after the first full moon of spring....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • why is this wrong for vectors vector<char> decrypt{ {'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',...

    why is this wrong for vectors vector<char> decrypt{ {'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A'}, {'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'}, }; for(int...

  • Need help in c++ programming to output the lines in my code: if word if found:...

    Need help in c++ programming to output the lines in my code: if word if found:            cout << "'" << word << "' was found in the grid" << endl;            cout << "'" << word << "' was not found in the grid" << endl; The words can be touching if they are horizontally, vertically, or diagonally adjacent. For example, the board: Q W E R T A S D F G Z X C V B Y U A...

  • 2. Design the logic for a program that outputs every number from 1 through 15. 3....

    2. Design the logic for a program that outputs every number from 1 through 15. 3. Design the logic for a program that outputs every number from 1 through 15 along with its value times 10 and times 100. // please answer e, f, 2, 3 <----- 1. What is output by each of the pseudocode segments in Figure 5- 30? b. a. C. d=4 1 a = g4 h 6 while g< h b 2 e 6 f 7...

  • Name the following compounds Acids and Esters homework. 1. Name the following Compounds он OH Brown...

    Name the following compounds Acids and Esters homework. 1. Name the following Compounds он OH Brown golon он MacBook A 0. % 5 A 6 7 B 9 0 3 2 P W E R U T Y S D А F G Н. K ? Z с - V N B M Command option option command он OH НО- OH o D MacBook Air A * $ 4 % 5 & 7 3 6 8 9 0 W E...

  • Please explain the python code below L1 = [2, 15, 'Carol', 7.4, 0, -10, -6, 42,...

    Please explain the python code below L1 = [2, 15, 'Carol', 7.4, 0, -10, -6, 42, 27, -1, 2.0, 'hello', [2, 4], 23] print("L1 =",L1) odds =[] evens=[] list=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',',','.'] no=0 for i in L1: i=str(i) for j in list: if i.find(j)>=0: no=1 if no==1: None else: i=int(i) if i%2==0: evens.append(i) else: odds.append(i) no=0      ...

  • The trial balance columns of the worksheet for Wildhorse Roofing at March 31, 2020, are as...

    The trial balance columns of the worksheet for Wildhorse Roofing at March 31, 2020, are as follows. Wildhorse Roofing Worksheet For the Month Ended March 31, 2020 Trial Balance Account Titles Dr. Cash 4.700 Accounts Receivable 3,500 Supplies 1.780 Equipment 11,000 Accumulated Depreciation-Equipment 1.250 Accounts Payable 2,550 Uneared Service Revenue 570 Owner's Capital 12,600 Owner's Drawings 1.130 Service Revenue 6,800 Salaries and Wages Expense 1320 Miscellaneous Expense 23.770 23,770 340 Other data tv 2 $ 4 3 % 5 &...

  • Question 5 of 18 > The decomposition of N, O, can be described by the equation...

    Question 5 of 18 > The decomposition of N, O, can be described by the equation t(s) 0 165 406 795 [N,O31(M) 1.881 1.696 1.457 1.141 2N, O,(soln) -4NO, (soln) + 0, (g) Consider the data in the table for the reaction at 45 °C in carbon tetrachloride solution. Given the data, calculate the average rate of reaction for each successive time interval. What is the average rate of reaction for the time interval from 0 to 165 s? average...

  • Help with programming in Raptor: Many companies use telephone numbers like 555-GET-FOOD so the number is...

    Help with programming in Raptor: Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion: A, B, and C = 2 D, E, and F = 3 G, H, and I = 4 J, K, and L = 5 M, N, and O = 6 P, Q, R, and S = 7 T, U, and V = 8...

  • signment Score: 150/1800 Resources OH Question 7 of 18 > Consider the reaction described by the equation C,H, B...

    signment Score: 150/1800 Resources OH Question 7 of 18 > Consider the reaction described by the equation C,H, Br, (aq) + 31 (aq) -C,H,(8) + 2 Br" (aq) + 1; (aq) The rate law is rate = k[C,H, Br,1"] where k = 0.00508 M-.5-1 What are the missing entries in the table? Run 0.173 Initial rate of formation of 0.000608 0.000304 0.173 0.173 0.173 SO E U | R T Y D F G H J K. C V B...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT