Easter calculator

Hello guys I need your help im really new in C++ and I need to do easter calculation to get the right easter day, at the moment I could get one year.
Example:
Year 2015
Easter Day in 2015 is/5/4/2015Year

but my professor is asking me to get year range

Example:
Year 2015 2020
Easter day in 2015 is 5/4/2015
Easter day in 2016 is 5/8/2016
........
Easter day in 2020 is ....

The problem that have is I don't know how to start at the moment I just have integer to calculate year how can I have two integers? and then guess I need while and increment or how can I do it ? please help me out guys! I would really appreciate this my code so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  
#include<iostream>
using namespace std;
int main()
{
    int year, date, month;
    int a, b, c, d, e, f, g, h, i, j, k, m, p;
    do {
        cout<< "Year ";
        cin >> year;
       
        
       
        
        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;
        j=c%4;
        k=(32+(2*e)+(2*i)-h-j)%7;
        m=(a+(11*h)+(22*k))/451;
        month=(h+k-(7*m)+114)/31;
        p=(h+k-(7*m)+114)%31;
        date=p+1;
        cout << "Easter Day in" << " " << year << " " << "is"  << "/" << date  << "/" << month << "/" << year;
        
    }
    
    while (year>=0001&&year<=5000);
    
    
    return 0;
    
   
}


Thanks for your cooperation :)
Hi,

I have always wondered how the Easter date was figured out, Now I know ! :+D. I thought it was something to do with first full moon after Lent (whenever that is).

OK, with the formulae in your code, it seems everything is dependent on the year. So create a function which gets input for the start and ending year. Put some validation code in that function, use references so both values can be available in main's scope. Then have another function which takes years as an arguments, have a for loop, calculate the date and print it.

At the moment you do loop is not achieving much. And this year>=0001 doesn't work like you think it does. A leading zero on a number means that it is octal, it doesn't make any difference here, it's value is still 1, but try to avoid doing that. The number 1 is sufficient.

Does your formula still work for such an early date? The calendar was reorganised back in 1753 IIRC (I was 10 then :+D) They added in August at some point and there were other changes too.

Always initialise your variables to something, this is one of the biggest problems generally and will save you one day. Declare & initialise 1 variable per line, and put a comment to say what the name means.

Think about the types, could they all be unsigned? What happens if a negative value is put in?

Good Luck !!
Topic archived. No new replies allowed.