+ 4

Can assignment operators switch += to =+ and if so how dose it change the code

Just asking a question

25th Nov 2019, 12:06 AM
Cameron Phillips
Cameron Phillips - avatar
39 Answers
+ 2
To everybody who enjoys so much reading their own sentence in a 'hot today' thread: You'd learn a lot more if you actually READ a discussion before you just thoughtlessly add another half-baked guess like a dozen people did before you.
26th Nov 2019, 10:56 PM
HonFu
HonFu - avatar
+ 9
Have you tried this in a program? That's the first thing you should do if you have this sort of question.
25th Nov 2019, 12:29 AM
HonFu
HonFu - avatar
+ 5
Try it with -= and =-. Print out the value. Tell us what you found.
25th Nov 2019, 12:38 AM
HonFu
HonFu - avatar
+ 5
Alyssa your links are irrelevant.
26th Nov 2019, 3:55 AM
Sonic
Sonic - avatar
+ 4
Do you know, how a regular assignment works? With only = ? (Sorry I'm a bit like one of these teachers right now who want you to read their mind. ^^)
25th Nov 2019, 12:54 AM
HonFu
HonFu - avatar
+ 4
You can += adds the together and changes value with the sum =+ changes value and makes the number a positive number or =- makes the num a negative number
25th Nov 2019, 5:17 PM
Cameron Phillips
Cameron Phillips - avatar
+ 3
You got it. 🙂
25th Nov 2019, 5:35 PM
HonFu
HonFu - avatar
+ 3
it can work
25th Nov 2019, 6:26 PM
TINGAN JEFF
TINGAN JEFF - avatar
+ 3
amen HonFu
27th Nov 2019, 8:36 AM
Brave Tea
Brave Tea - avatar
+ 2
Try and find out yourself. Do you have a computer?
25th Nov 2019, 12:34 AM
Logomonic Learning
Logomonic Learning - avatar
+ 2
Thank you I appreciate all the help
25th Nov 2019, 1:24 AM
Cameron Phillips
Cameron Phillips - avatar
+ 1
Yes but to be honest it didn't give me a error but I wasn't sure how it change the execution of the of the operation
25th Nov 2019, 12:32 AM
Cameron Phillips
Cameron Phillips - avatar
+ 1
Int num1 = 4 , num2 = 8 Num2 += num1 Gives output 12 I get that it changes num 2 to num2+num1 but the other way around gives both num1 and num2 the assignment 4
25th Nov 2019, 12:42 AM
Cameron Phillips
Cameron Phillips - avatar
+ 1
Try what I wrote.
25th Nov 2019, 12:47 AM
HonFu
HonFu - avatar
+ 1
Do you understand how it works?
25th Nov 2019, 12:47 AM
Logomonic Learning
Logomonic Learning - avatar
+ 1
Should I be looking at it like a algebraic problem
25th Nov 2019, 12:49 AM
Cameron Phillips
Cameron Phillips - avatar
+ 1
I think so, it assigns a value to a identifier
25th Nov 2019, 1:02 AM
Cameron Phillips
Cameron Phillips - avatar
+ 1
int x = 5 //x is a key 5 is the value x-=2 // same as x=x-2 so x is now 3 because x=5-2=3 y=-2 // y is key with value of -2
25th Nov 2019, 1:09 AM
Logomonic Learning
Logomonic Learning - avatar
+ 1
Lost me on that one
25th Nov 2019, 1:12 AM
Cameron Phillips
Cameron Phillips - avatar
+ 1
Int x =5 , y = -7 y=+x out put for both x and y 5 X=+y out put for both x and y -7 So the only thing I can come up with is it acts as if the + is not there when it is on that side
25th Nov 2019, 1:18 AM
Cameron Phillips
Cameron Phillips - avatar