why can't we use this like x=+2 insted of x+=2?? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 3

why can't we use this like x=+2 insted of x+=2??

7th Sep 2018, 7:17 AM
Sowmiya
Sowmiya - avatar
15 Réponses
+ 1
than... what u will do.. when u need to store 2 with negative value.. x= -2 than .. it cant store negative it will operate it as.. x=x-2 .... 😜
8th Sep 2018, 11:29 AM
DSYr4Hp
DSYr4Hp - avatar
+ 6
my doubt is cleared. . thank you all.....
7th Sep 2018, 9:44 AM
Sowmiya
Sowmiya - avatar
+ 4
l have this doubt in c language....
7th Sep 2018, 7:26 AM
Sowmiya
Sowmiya - avatar
+ 4
thank you . i think this will be the correct ans. to clear my doubt...
7th Sep 2018, 7:34 AM
Sowmiya
Sowmiya - avatar
+ 4
You can use x=+2 but it means something different. Namely assigning a positive 2. That's why i prefer using spaces, you'll notice the difference much better: x = +2 (plus belongs to 2) x += 2 (plus belongs to operator)
7th Sep 2018, 9:10 AM
Matthias
Matthias - avatar
+ 3
ya sure....thank you...
7th Sep 2018, 7:40 AM
Sowmiya
Sowmiya - avatar
+ 2
hi, what language are y talking about? In some language you can use both (with different effect )
7th Sep 2018, 7:21 AM
Nifriz
Nifriz - avatar
+ 2
I don't use C, and I don't know if is possible use both. I remember this about C++ x=1 cout<< x=+2 this print 1 and after add 2 cout<<x+=2 this sum 2 snd after print 3
7th Sep 2018, 7:32 AM
Nifriz
Nifriz - avatar
+ 2
Matthias i didn't downvote you! maybe someone else, not me.
7th Sep 2018, 10:26 AM
Nifriz
Nifriz - avatar
+ 2
Tind Perfect, Tind.
7th Sep 2018, 6:08 PM
Angelo Sorte
Angelo Sorte - avatar
+ 1
Because languages has own rules and own grammatic
7th Sep 2018, 7:39 AM
KrOW
KrOW - avatar
+ 1
Matthias maybe is another language and I made confusion
7th Sep 2018, 9:29 AM
Nifriz
Nifriz - avatar
+ 1
No need to downvote my comment though
7th Sep 2018, 9:31 AM
Matthias
Matthias - avatar
0
Daniele Baitieri This is wrong. This won't even compile, because you can't assign a value in a cout statement. What you probably meant is pre and post increment int x = 1; cout<<x++; //prints 1, x is 2 afterwards cout<<++x; //prints 2, x is 2 afterwards
7th Sep 2018, 9:16 AM
Matthias
Matthias - avatar
0
thank you for made me analyse ..that my assumption is wrong...
8th Sep 2018, 11:48 AM
Sowmiya
Sowmiya - avatar