SubhanUllah Posted October 19, 2022 Report Share Posted October 19, 2022 In C the result for the variable is the same after the instruction. The difference is where you put the ++; in front or behind the variable. so a=0 a++ ++a a+=1 make a = 3 a = 0 b = a++ // c is assigned first and is 0, then a becomes 1 c = ++a // a becomes 2 then c is assigned the 2 a += 1 // a becomes 3 Make a = 3 but b = 0 and c = 2 , When the ++ is last, the assignment is done first then the value of ‘a’ is bumped by one. Without the equal sign they are all the same; ‘a’ goes up by one. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.