what is difference between " = "and" == " in Programming? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

what is difference between " = "and" == " in Programming?

25th Dec 2018, 4:57 PM
WASEEM MEHR
WASEEM MEHR - avatar
7 Antworten
+ 7
= assignment operator a=5; assigns value of 5 to a == equality operator if a=5,b=6; a==b; Checks whether they both are equal here output is false
25th Dec 2018, 5:02 PM
deeyae
deeyae - avatar
+ 4
= is used for assignment And == is used for comparison Simple is that
22nd Jan 2019, 6:37 AM
MINAHIL_HUSSAIN
MINAHIL_HUSSAIN - avatar
+ 2
= this is called assignment operator use to assign value Example Int a=2; Var b=20; == This is called comparison operater use to compare to value mostly in if , else conditions . Example If ( a==b) { Console.WriteLine("ok"); } If ( a==b) { Document.Write("ok"); }
31st Jan 2019, 6:09 PM
Muhammad Tayyab
Muhammad Tayyab - avatar
+ 1
and there is also === You can use this to compare two variables or values AND it checks if the type (string, number, boolean) is the same.
26th Dec 2018, 8:27 AM
marjel101
marjel101 - avatar
+ 1
There are three kinda operators usage 1) x=5, y=3+2 are assignment of value 2) x==y is equation of values, that compares values of variables 3) x===y is kind of a strict equation which compares value and type of variable. (e.g. x=3+2, y='3+2' doesnt gets the same result) Almost the same concept applies to +, ++ OR mixed +=, -= according to the operators nature.
28th Jan 2019, 5:10 AM
Taͣlhͪaͣ_ͥ
0
in my words "=" is use for assign the value to variables and its also called assignment opreator on the other hand "==" is use for compare the value of variable.
25th Dec 2018, 5:01 PM
WASEEM MEHR
WASEEM MEHR - avatar
0
= is assignment operator: example: if you will reffer to a value more than once in your program, you may want to assign that value to a variable like this: myValue = "SoloLearn". and == is a comparison operator .... so when you want to make so comparisons on values or types of values you will use it example: valid_age = 18 my_Age = 18 valid = my_age == valid_age in this example I compared numbers. :)
2nd Jan 2019, 11:51 PM
Edwing123
Edwing123 - avatar