I tend to get abit confused with the assignment operators such as: += & -=.

If i have this code

int i = 3;
i += 3;

Does that say i + i = 3 which will make i have a new value of 6?

This is another example that I get confused with:

milesTraveled = endingMileage -= startingMileage;
amountOwed = milesTraveled *= reimburseRate;

Does this say endingMileage - startingMileage = milesTraveled? same with the second line?

Could someone please explain to me how assignment operators work if I am worng?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.