in loop coding... is "x=x+2" and "x+=2" same? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

in loop coding... is "x=x+2" and "x+=2" same?

29th Aug 2017, 3:10 AM
Sagar Ambastha
Sagar Ambastha - avatar
7 Answers
+ 11
x=x+2 //general form x+=2 //shorthand assignment operator both are same not only in loops but everywhere
29th Aug 2017, 4:44 AM
P R
P R - avatar
+ 6
Yes, they are the same wether in a loop or not.
29th Aug 2017, 3:35 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
yes it is the same
14th Jan 2018, 7:41 AM
Tobias Müller
Tobias Müller - avatar
+ 2
Yes it is the same
14th Jan 2018, 4:00 PM
Brian Kathukya
Brian Kathukya - avatar
+ 2
In C++,both the things are same,u can use anyone according to ur wish.
16th Apr 2018, 6:45 AM
DEBAYAN BHAUMIK
DEBAYAN BHAUMIK - avatar
+ 1
Same
15th Jan 2018, 7:25 AM
Md Abdus Sobur Sikdar
Md Abdus Sobur Sikdar  - avatar
+ 1
yup they are same as long as u want in c++
17th Jan 2018, 2:35 AM
Sumit Bibiyan
Sumit Bibiyan - avatar