c - Can't understand x *= y+1 output -


I have a problem understanding code output. Please clarify any ...

  # Includes & lt; Stdio.h & gt; Zero main () {int x = 2, y = 5; X * = y + 1; Printf ("% d", x); }  

Output is in the form of 12. But according to my understanding, x * = y + 1; is x = x * y + 1; but according to the preference of the operator, x * y should be evaluated after which add 1 , so it should be 10 + 1 = 11. But this is 12 - can anyone please explain?

What's happening here is the order of operation in programming.

Yes, if you have this equation x * y + 1 then it will be (x * y) + 1 and the result is eleven.

But the equation on the right side of the = symbol is resolved before being modified by the = symbol in the programming. Signal In this equation it is multiplied.

then x * = y + 1 is actually x = x * (y + 1) which will be 12. = ^ In this case, asterisk (*) is multiplying the whole equation by x on the right hand and then specifying the result x .


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -