+ 3
why can't we use this like x=+2 insted of x+=2??
15 Answers
+ 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 .... š
+ 6
my doubt is cleared. .
thank you all.....
+ 4
l have this doubt in c language....
+ 4
thank you . i think this will be the correct ans. to clear my doubt...
+ 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)
+ 3
ya sure....thank you...
+ 2
hi, what language are y talking about? In some language you can use both (with different effect )
+ 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
+ 2
Matthias i didn't downvote you! maybe someone else, not me.
+ 2
Tind Perfect, Tind.
+ 1
Because languages has own rules and own grammatic
+ 1
Matthias maybe is another language and I made confusion
+ 1
No need to downvote my comment though
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
0
thank you for made me analyse ..that my assumption is wrong...