+ 1

[DUPLICATE] What is difference between i++ and ++i

24th Apr 2018, 4:23 AM
Saran
Saran - avatar
9 Answers
+ 5
post increment = x++ pre increment = ++x int x = 5; int y = x++; Now x is 6 and y is 5. int x = 5; int y = ++x; Now both x and y are 6. The pre-increment first do increase/decrease of the variable and next some operetions. The post-increment do some operations first and at the end increase variable.
24th Apr 2018, 5:04 AM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
+ 5
a = i++ means variable a is set to the value of i, then value of i is added by 1, so a!=i a = ++i means value of i is added by 1, then a is set to value of i, so a==i
1st Jun 2018, 1:21 PM
Christopher
Christopher - avatar
+ 3
When using post-increment (i++), the expression is evaluated first and then the value of the variable "i" gets incremented by 1. In case of pre-increment (++i), the value of variable "i" is first raised by 1, and then the given expression is evaluated. edit: Saran hope this helps. https://code.sololearn.com/cGm5AK5vHiUz/?ref=app
24th Apr 2018, 4:35 AM
Rahul George
Rahul George - avatar
+ 3
i++ is called post increment.... Current value of i is used to evaluate the statement and then increment value of i by 1. ++i is pre increment... Here value of i incremented by 1 and incremented value is used in the given statement. Int i = 5; Print i++ 5 Print ++i 6
24th Apr 2018, 5:36 PM
Parveen D
Parveen D - avatar
+ 2
Nice Deepak....
24th Apr 2018, 5:32 AM
Saran
Saran - avatar
+ 1
give an example program
24th Apr 2018, 4:37 AM
Saran
Saran - avatar
+ 1
Tks bro
24th Apr 2018, 5:05 AM
Saran
Saran - avatar
0
Saran it's my pleasure.
24th Apr 2018, 5:06 AM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar