Hindi, asked by CrimsonHeat, 10 months ago

what is the difference between == in relational operators and = in assignment operators

no spamssss...will be deleted


mohitparmar: hi

Answers

Answered by Sandhyathakur
2
single equals "=" and double equals "==" are different in multiple languages including C,C++,Java, Javascript, etc.

The difference is that = sets a variable to the given value, and == compares the value stored in a variable with the given value. For example:

x = 2 (now the value 2 is set to x)

x == 3 (checks if the value in x is 3; if so, returns true, else returns false) will return false, as the value of x is 2.

Sandhyathakur: o my god...but tention na lo.accha hoga.
Sandhyathakur: hmm ab aap padhai karo.distarb ni karungi
Answered by nilesh102
0

hi mate,

Answer:

Many times this question arises what is the difference between = and == operators in C programming language? Here we are going to tell you exactly what the differences between these two operators are.

Assignment Operator (=)

= is an Assignment Operator in C, C++ and other programming languages, It is Binary Operator which operates on two operands.

= assigns the value of right side expression’s or variable’s value to the left side variable.

Let's understand by example:

Let's understand by example:x=(a+b);

Let's understand by example:x=(a+b);y=x;

Here, When first expression evaluates value of (a+b) will be assigned into x and in second expression y=x; value of variable x will be assigned into y.

Equal To Operator (==)

== is an Equal To Operator in C and C++ only, It is Binary Operator which operates on two operands.

== compares value of left and side expressions, return 1 if they are equal other will it will return 0.

Let's understand by example:

Let's understand by example:int x,y;

Let's understand by example:int x,y;x=10;

Let's understand by example:int x,y;x=10;y=10;

Let's understand by example:int x,y;x=10;y=10;

Let's understand by example:int x,y;x=10;y=10; if(x==y)

Let's understand by example:int x,y;x=10;y=10; if(x==y) printf("True");

Let's understand by example:int x,y;x=10;y=10; if(x==y) printf("True");else

Let's understand by example:int x,y;x=10;y=10; if(x==y) printf("True");else printf("False");

When expression x==y evaluates, it will return 1 (it means condition is TRUE) and "TRUE" will print.

Conclusion

So it's cleared now, ,both are not same, = is an Assignment Operator it is used to assign the value of variable or expression, while == is an Equal to Operator and it is a relation operator used for comparison (to compare value

I hope it helps you.

Similar questions