Modulo Syntax Error

I am confused why Visual Studios says that after "century)" right before the "% 7;" there needs to be a semicolon. It says I made a syntax error. But I want to take that whole thing in parentheses and then do the modulo 7 to it. Help?


int determineDay(int month, int day, int year) {

const int HUNDRED_YEARS = 100;
int newYear = year % HUNDRED_YEARS;
int century = (year - newYear) / HUNDRED_YEARS;


if (month == 1) {
const int ONE_YEAR = 1;
month = 13;
year = year - ONE_YEAR;
int zellerNumber = (day + floor((13 * (month + 1)) / 5)) + year
+ floor(year / 4) + floor(century / 4) + 5 * century) % 7;
return zellerNumber;

}
else if (month == 2) {
const int ONE_YEAR = 1;
month = 14;
year = year - ONE_YEAR;
int zellerNumber = (day + floor((13 * (month + 1)) / 5)) + year
+ floor(year / 4) + floor(century / 4) + 5 * century) % 7;
return zellerNumber;
}

else {
int zellerNumber = (day + floor((13 * (month + 1)) / 5)) + year
+ floor(year / 4) + floor(century / 4) + 5 * century) % 7;
return zellerNumber;
}

}

The modulus operator requires two integer values but floor() returns a double. Since all of your variables appear to be integers you probably don't need floor() as there are no fractions with integer math.


Topic archived. No new replies allowed.