+ 3

What would happen when we use if(++) or if(1)?

if condition

24th Apr 2018, 12:23 PM
Elham Keshavarz
Elham Keshavarz - avatar
5 Answers
+ 1
You should try... the compiler does not compile if for if(++). You can do a if(i++): https://code.sololearn.com/cFJHSRSQBG0U
24th Apr 2018, 12:37 PM
jerome
+ 3
jerome so,if(i++) and if(1) is always true ,right?
24th Apr 2018, 12:40 PM
Elham Keshavarz
Elham Keshavarz - avatar
24th Apr 2018, 12:42 PM
Elham Keshavarz
Elham Keshavarz - avatar
+ 1
If(++) is incorrect and causes an error. any number different than 0 is always true.
24th Apr 2018, 12:26 PM
Bartosz Pieszko
Bartosz Pieszko - avatar
+ 1
Elham Keshavarz execute the code if(i++) return false. if(i=i+1) return true as the assignment is done correctly.
24th Apr 2018, 12:53 PM
jerome