< Prev
Next >



Increment Operator in C












a++ - 10
  1. Due to post-increment operator with a, its value 10 is first read to be subtracted by 10.
  2. Next, the original value of a is incremented to 11.
  3. Finally, result of 10-10 = 0, is passed to the result.



++b - 10
  1. Due to pre-increment operator with b, its value 10 is first incremented to 11
  2. Next, this incremented value of b, 11 is subtracted by 10
  3. Finally, result of 11-10 = 1 , is passed to the result.



++c - 10 + c++
  1. Due to pre-increment operator with c, first its value 10 is incremented to 11
  2. Next, this incremented value of c 11 is subtracted by 10, which results to 1.
  3. In the next expression, due to post-increment operator with c, first the current value of a, 11 is read and added to 1 and then a is incremented to 12.
  4. Finally, the result of 1+11 = 12, is passed to the result.



d++ + ++d +10
  1. Due to post-increment operator with d, first its value 10 is read to be added to the next expression and then its value is incremented to 11.
  2. In the next expression, due to pre-increment operator with d, its current value value 11 is incremented to 12.
  3. Next, due to d++ + ++d, leads to 10 + 12, which results to 22, which is added to 10.
  4. Finally, the result of 22+10 = 32, is passed to the result.




Please share this article -

Facebook Google Pinterest Reddit Tumblr Twitter



< Prev
Next >
< Arithmetic Operator in C
Decrement Operator in C >

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page

Notifications



COMING SOON
-
PYTHON