-1
    int d = year%100;
    int c = year/100;
    int valueA = (int)(((13*monthnumber)-1)/5);
    int valueB = (int) d/4;
    int valueC = (int) c/4;

    int weekDay = (d + valueA + d + valueB + valueC - 2*c);

    int remainder %= weekDay/7; 

im trying to use the modulus assignment operator but keep getting a system error saying that an '=' was expected instead of '%='

code in question is the last line

please help

user3185727
  • 159
  • 1
  • 3
  • 12

4 Answers4

2
int remainder %= weekDay/7; 

would be equivalent to

int remainder = remainder % weekDay/7; 

which makes no sense since you just declared remainder, so it has no previous value.

Had you declared the remainder variable earlier, this would work :

remainder %= weekDay/7; 
Eran
  • 374,785
  • 51
  • 663
  • 734
2

%= can't be used for variables that haven't had a value assigned yet.

var %= {value};

is equivalent to

var = var % {value};

But in the way you're using it, remainder hasn't had a value assigned to it yet. So it makes no sense.

Xirema
  • 19,266
  • 4
  • 30
  • 64
1

because with int remainder you are declaring a variable, and its initialisation cannot be achieved with %=

gefei
  • 18,124
  • 7
  • 49
  • 65
1

You probably just meant to do this:

int remainder = weekDay % 7;
sstan
  • 33,933
  • 6
  • 42
  • 65