0
What is the difference between Post and Pre increment?
Sir I wrote this i = 1 i =+ 5 print(i) Output: 5 Doubt: sir it should show 6 ryt? Also when I tried += then it showed me 6. So, which one is correct sir? I AM CONFUSED THAT HOW THESE TWO ARE DIFFERENT.... :( Also the names I got from google (that post and pre increment) So clarify please sir :(
2 Réponses
0
Hi! In your example this is no post or pre increment. See this:
++x - pre,
x++ - post
0
When we increase the value of a variable before assigning it to another variable then it is known as Pre-Increment. When the value of a variable is incremented after assigning it to a variable, it is known as Post-Increment.
See: https://bitdifference.com/post-vs-pre/