Ok...i am doing a school project...basically you input a year and it will tell you what date easter falls on in that year. Believe it or not...there is a mathematical way to find it out. Check this out:
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int year, b, c, a, s, r, t, h, g, j, k, m, n, q, p;
char month;
cout<< "This program designed by Shiv (in C++) will find the date of Easter in the year you choose... \n";
cout<< "Please choose the year: ";
cin>> year;
cin.ignore();
b = year / 100;
c = year % 100;
a = (5*b + c) % 19;
r = (3*b + 75) / 4;
s = (3*b + 75) % 4;
t = (8*b + 11) / 25;
h = (19*a + r - t) % 30;
g = (a + 11*h) / 319;
j = (300 - 60*s + c) / 4;
k = (300 - 60*s + c) % 4;
m = (2*j - k - h + g) % 7;
n = (h - g + m + 110) / 30;
q = (h - g + m + 110) % 30;
p = (q + 5 - n) % 32;
if (n = 4) {
char month = "April";
}
if (n = 3) {
char month = "March";
}
cout<< "In year "<< year<<", Easter will be on Sunday "<< p<<" of "<< month;
cin.get();
}
In the code...the interger n is either 3 or 4, if it is 3 the month is march, if it is 4 the month is april...so im trying to make if statements to do the recognising...but its not working:
Code:
if (n = 4) {
char month = "April";
}
if (n = 3) {
char month = "March";
}
Any help to doing it would be greatly appreciated...thanks.