+ 1

# whats the difference between = and ==?

23rd Jun 2016, 12:16 PM
TheBurningPhanttom + 9
= is assignment operator. it will assign the right side value to the left side variable. == is logical equal operator. it will compare lhs and rhs are same or not. If both are same it will return true otherwise it returns false. For eg: int a; a = 10; // we are assigning 10 to variable 'a' bool equal = (9 == a); // here we are comparing a is equal to 9 or not. In our case a is 10, so equal will be assigned to false. Hope you understand this
23rd Jun 2016, 12:26 PM
Venkatesh(Venki) + 2
= is a assignment operator and == is a equal sign
24th Jun 2016, 7:48 AM
seyfullah + 1
= set value == compare value
13th Sep 2016, 7:42 PM 0
here's a example : if(x==0){x=5;} Now let's talk about this. First the == checks if the first statement (x) is equal to the second (0) , but then the = is gonna assign the value of 5 to x. I hope you got it.
23rd Jun 2016, 12:26 PM
Alex Ban 0
thanks
23rd Jun 2016, 12:31 PM
TheBurningPhanttom 0
'=' is for assigning values to variables.. and "==" is for checking whether two variables are equal.. and it is used in conditioning statements
25th Jun 2016, 3:42 PM
abdo
0
awesome
26th Jun 2016, 12:53 AM
Main Hun SB - 1
= sets variable to something == looks if it is the same
3rd Jul 2016, 5:16 AM
Hansi Reit - 5
= means similar but ==must be same
24th Jun 2016, 6:50 PM
Hirak Dey 