+ 6
What is difference between if(1=2} and if (1==2),in first case result is 1,in second 0, please,explain me,why ??
В чем разница объясните -გთხოვთ ამიხსნათ- რაშია განსხვავება? <thanks,спасибо,მადლობა>
11 Answers
+ 10
= assigns
== compares
if operator check a condition if condition true then reply 1 or else 0
thats why second reply 0 because 1!=2
for first reason there is a rule in c
"C reply ‘true’ in non-zero always"
so u assign a non zero element so its return 1
if the condition is like if(0) then its reply 0
or if(a) its return 1.
hope u understand☺
+ 5
then mark best answer ☺☺
i am friend of every sololearians ☺
+ 4
= assigns
== compares
+ 4
ooo..
go to ur email that connected to ur sl account
there is a email from sl
click activate then u'll able to like
☺
+ 3
@Scooby you are my friend from this moment :)
+ 3
David stark you are miracle :)
+ 3
@Scoobyl cann't like anyone,sololearn answers me that l am not connected,l don't understant a reason,can you suggest me something(help) once again :)
+ 2
u too ♥
+ 2
@luka ara dzma gavige,madloba
+ 1
nice explain
l will try it,thanks so much,good luck in proggraming ♡(all sololearns)♡
+ 1
'if(1=2)' this is like you are assigning the value of 2 to 1 just like saying if 1 is 2 but for..that is 1 is now been giving the value of 2 so the result will be true or 1
'if(1==2)' in this case you are comparing the values..like saying if 1 is the same thing as 2...
therefore '=' and '==' are two different things in c++ programming that is why for the second the result was zero because 1 is not the same thing as 2...