0
Here’s my code, why is there a change in the other variables, I’m not just changing the line line to variable value? why the others change?
int a = 1, b = 2, c = 3, valor = 0;
valor = a;
printf("%d\n" , valor);
valor = b++;
printf("%d\n", valor);
valor = ++c;
printf("%d\n", valor);
valor += b;
printf("%d\n", valor);
valor *= c;
printf("%d\n", valor);
then the statement for example: value=++b , is adding +1 in variable b in addition to changing a b , that’s it?
– Vitor Gonçalves
@Vitorgonçalves yes, this is increment operator, so it will add first to the variable b
– Fábio Morais
summarizing: increment and decrease change the variables , no longer assignment?
– Vitor Gonçalves
@Vitorgonçalves exactly, when doing value = b++; //here the "b" would have the value of 2 value = b; // here the "b" would have the value of 3 value would have the value of 3, because when doing b++ then increments next
– Fábio Morais
is a bit confusing, especially when ++ is in front of the kk variable, it 'calculates' but does not 'apply' the same as ++ ago , it is complicated but an hour will , thank you!! :)
– Vitor Gonçalves
x++ calculates but does not apply soon; ++x calculates and applies. Think this way for ease
– Fábio Morais