+ 2

What is the difference between = and == operators?

25th Jul 2017, 3:11 PM
Prrathyush
Prrathyush - avatar
4 Answers
+ 14
@Jonas is correct. = is used to assign values to a variable. E.g int x = 16; == is used to evaluate if LHS and RHS expression is equal in value. if (x == 16) // do something
25th Jul 2017, 3:25 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
= is an assignment operator, it assigns a value to a variable. == is a comparison operator.
25th Jul 2017, 3:15 PM
Jonas Schröter
Jonas Schröter - avatar
0
single = mean it assign the value toward left side for example y=4 this mean the value of y is 4. double == this straghtly mean "equal" for example y=4 and x=4 you can see both have equal number that's way this is used.
25th Jul 2017, 3:51 PM
Irwin Lopez
Irwin Lopez - avatar
0
thanks for the answer...!!!!
18th Aug 2017, 4:23 PM
Prrathyush
Prrathyush - avatar