+ 1

# whats the difference between = and ==?

9 Answers

+ 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

+ 2

= is a assignment operator and == is a equal sign

+ 1

= set value == compare value

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.

0

thanks

0

'=' is for assigning values to variables.. and "==" is for checking whether two variables are equal.. and it is used in conditioning statements

0

awesome

- 1

= sets variable to something
== looks if it is the same

- 5

= means similar but ==must be same