The ‘==’ operator is not the same as the assignment operator ‘=’. (True or False).
Answers
Answer: TRUE
== operator is the relational operator
= operator is the assignment operator
Relational Operators:
>= , <= , == , != , < , >
Assignement Operators:
= , += , -= , *= , /= , %=
The ‘==’ operator is not the same as the assignment operator ‘=’ True
Explanation:
The given statement is True.
The sign with single ‘=’ is an ‘assignment’ operator. It is used to assign a value or an expression to the variable. Whereas, sign with two ‘==’ is an ‘equal’ operation and it compares the right expression with the left expression. It is used in programming to check if left is equal to right or not, then perform corresponding action. Hence, both these operators doesn’t mean the same.
For example, x=5, means the assignment operator ‘=’ has assigned the value 5 to variable x.
If a=3 and statement is If (a==5), this will return false as ‘==’ will check if left expression is equal to right, which is not. The value of a is 3.