Never coded before... I know video says x++ is same as saying x=x+1 but why do we use this x++ in this code? in other words why | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Never coded before... I know video says x++ is same as saying x=x+1 but why do we use this x++ in this code? in other words why

8th May 2017, 1:51 PM
Sai Venkat
Sai Venkat - avatar
7 Answers
+ 10
@Sachin Artani That longest world comment ever again \(O_O)/
8th May 2017, 2:14 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 7
x=x+1 Return x 2 times While x++ Return x 1 time So x++ is the faster way
8th May 2017, 1:59 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 5
For better speed, developers reduce a little burden of programmers by reducing length of instructions. It's completely on you to use x++ or x=x+1, both results the same. Also, if you want to know the difference between x++ and ++x, please check this code- https://code.sololearn.com/cjHQRJUG5NTf/?ref=app
8th May 2017, 2:13 PM
Sachin Artani
Sachin Artani - avatar
+ 5
😁😁😁 @Very hard, yes! I sorted out everything I knew about ++x and x++ in a single code.
8th May 2017, 2:14 PM
Sachin Artani
Sachin Artani - avatar
+ 3
is more easy to type x++ than x=x+1 furthermore x++ have more 'semantic meaning' that is to say, express better what we need to do
8th May 2017, 1:55 PM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar
0
It is not only a matter of speed or length of code. The assignment operator (=) returns the value of th right hand expression (in that case, x+1), while x++ returns the value of x before incrementing.
8th May 2017, 5:11 PM
Denis Felipe
Denis Felipe - avatar
0
how to write algorithms because when it comes to codes I'm a bit good, I'd need someone to help me with how to write an algorithm when it comes to conditions and loops
8th May 2017, 5:14 PM
LongTom
LongTom - avatar