What is the difference between " = " and " == " ?? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
+ 12

What is the difference between " = " and " == " ??

10th Jan 2017, 9:27 AM
Himanshu Singh
42 Antworten
+ 61
= is assignment, like if you wanna assign x as 2, you do int x = 2. == is comparison, if you wanna compare x and 2, you do if (x == 2), either true or false.
10th Jan 2017, 9:30 AM
David Sebastian Keshvi Illiakis
+ 8
"=" is an assignment operator which is used to assign value to the variable ex: int b=7; "==" is a relational operator which is used to find the relation between two operands and returns in boolen value either 'true' or 'false' example: 5==5 Condition true Returns 1 or true
11th Jan 2017, 7:36 PM
Abdullah Sharjil
+ 4
single `=` means you are giving the value example a=2 and == means equal sign with this will returm is true or false example 1==1
12th Jan 2017, 4:46 AM
ARNAB BISWAS
+ 3
"=" is used to assign the value. Example: x = 2, then value of x is 2. "==" is to show equality between values, Example x == y, here the value of y equal to x.
11th Jan 2017, 4:37 PM
N1H4R
+ 3
= is used for assigning value eg- x=3 y=3 == is used for comparing whether the value is equal eg- if(x==y) comparing whether x is equal to y.
11th Jan 2017, 6:19 PM
Sushil Bajracharya
+ 3
= as in x=2 says give x the value of 2. Then on x's value will be two. This is an assignment operator as ot assigns x a value of two. == as in if(x==2) checks whether x has a value of 2. this is a relational operator as it looks how two things are similar dissimilar of do they fall in the same category like if (x <2).
12th Jan 2017, 5:58 AM
prabin
+ 2
first one is assignment operator, and second one is equal operator
10th Jan 2017, 7:28 PM
Nawaj Shareef
+ 2
some compilers will warn you, but you need to be careful not to put something like "if (x=5)" since this will return true and assign 5 to x regardless of what x is.
12th Jan 2017, 5:01 AM
Ted Roesch
+ 2
(=) is a Assignment Operators, for assigning a value to a variable. (==) is a Relational Operators, checks the relationship between two operands. Example: x = 10; Now 10 is assign to the variable x. 5 == 10; checks whether the relation is equal or not.
12th Jan 2017, 5:02 AM
Md. Mahfuzur Rahman
+ 2
= also known as the assignment operator it assigns the value of its right hand side element to the value of its left hand side .I. e if a=b then the value of b is assigned to a on the other hand == is used for the comparison of elements other than string types
17th Jan 2017, 3:49 AM
ANKIT SHARMA
+ 2
= is a assignment operator but == is logical operator
20th Jan 2017, 4:58 AM
Saroj Nayak
+ 1
= is used to assign value to a variable. the value can be number or alphabet , that depends on the programmer and the program. And == is used to compare the value.
11th Jan 2017, 12:41 PM
Karnajeet Sawant
+ 1
= is nothing but assigning a value for a variable...for example a=5...this means that the value 5 is stored in memory location a...== is a relational operator...... means checks the equality of variables..i.e., checking whether the value belongs to that variable or not...
11th Jan 2017, 2:52 PM
+ 1
this is an assignment operator eg. i=5; this is conditional operator eg. if (i==5)
11th Jan 2017, 5:34 PM
Tenny Brown
+ 1
= is known as asssingment operator used for Assing the number to variable while == is used for comparison
11th Jan 2017, 6:00 PM
+ 1
I think if you need the traditional equality sign that we use in maths, you should use "==", while if you want to set a variable like x to something, use the "=";
11th Jan 2017, 8:05 PM
koki Christopher Titewondze
+ 1
the = is an assignment statement , the value on the left of it will get a new value that's the result of the right of it. while the == is like asking if the right equals the left; and thus the answer will be yes or no..
11th Jan 2017, 8:28 PM
layth salah
+ 1
The '=' is the assignment operator, which assigns the value at the right hand side to the variable at the left hand side. Eg. x=4, here the value 4 is assigned to 'x'. On the other hand, '==' is the relational operator which is used to check whether the value on both the sides are equal or not. If true, it returns a boolean true or '1' and if false, it returns a boolean false or '0'.
11th Jan 2017, 8:59 PM
Abhi Gaur
+ 1
"=" mean that we assign value to a variable. Ex x=5 or x=b+1 or a=false "==" mean that we compare two values. Ex a=10 and b=20/2. Thus a==b.
11th Jan 2017, 10:06 PM