lvalue required as left operand of assignment?

Hello, I was trying to divide counter by 4 and use the number left over to set up a if condition, but the compiler told me that "lvalue required as left operand of assignment", can anyone take a look of my code? It seems the problem is at line 28, Thank you!

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
#include <iostream>
#include <iomanip>

using namespace std;
static int mass=0;
static int counter=0;
int main()
{
    int maximumWeight=0;
    cin >> maximumWeight;
    int individualCars[99999]={};
    int numberOfCars =0;
    cin >> numberOfCars;

    for (int i=1; i<numberOfCars; ++i)
    {
        int initialWeight =0;
        cin >> initialWeight;
        individualCars[i]=initialWeight;
    }

    for (int k=1; k<=numberOfCars; ++k)
    {
        mass += individualCars[k];
        if (mass < maximumWeight)
        {
            counter++;
            if (counter%4=0)
                mass =mass - individualCars[k-3];
                while (k= numberOfCars)
                    cout << numberOfCars;}
        else if (mass = maximumWeight)
            cout << counter;
        else if (mass > maximumWeight)
            cout << k;

    }

}
The problem is indeed on line 28:
if (counter%4=0)

Should be if (counter%4 == 0) // two equals signs .
(One = is assignment; two is for comparison for equality)

And, in fact, you also have that problem on lines 30 and 32 as well.
Topic archived. No new replies allowed.