If there is + or -sign in ahead of a variable, then what does it means??

For e.g. c+

Do you mean expressions like c+=5; or c-=5; ?

1 Like
ah, I see, I saw this question yesterday, and I thought you meant -5, or +5...I am stupid
ok right,
so usually there are these, for the positive signs first
var++, ++var, var += 5 . first and second statement increments the variable by exactly one, meanwhile the thirdstatement increment the variable by how much value you put on the right of the += symbol, I put 5 so, the variable will be incremented by 5. E.g 

int var = 2;
var++; //var becomes 3
++var; //var becomes 4
var += 5; //var becomes 9

now, after you have seen the example, you might be wondering, what's the difference between ++var and var++, this can be easily explained through a simple example


int var = 2;
int lol = var++;

the pseudo-code above is the same as

int var = 2;
int lol = var;
var = var + 1;


int var = 2;
int lol = ++var;

which is the same as

int var = 2;
var = var + 1;
int lol = var;

which means, that var++, return the original value, and then increment, while ++var increment first and then return the value, as for

var += 1 or var += 2 or anynumber,

is the same as

var = var + 1
var = var + 2
var = var + anynumber

now that you understand the positive sign, the negative sign is the exact same, except it decrement

1 Like

Yes. I meant that

These are short-hand operations. If it’s written that c+=(any expression) than that is equivalent to c=c+(expression). It works in a similar way for c-=exp as c=c-exp and other operators.