Question:
Please tell me the difference between = and == which are used in C language.?
nemo
2009-01-05 04:14:52 UTC
Please tell me the difference between = and == which are used in C language.?
Eleven answers:
Zaky
2009-01-05 04:34:22 UTC
The "=" is used for assigning a value to a variable,

for example, the value 12 is assigned to the variable x, x=12;



The "= =" is used for comparison, for example, if(x==12) checks whether the value of variable x is 12 or not.
anonymous
2016-04-08 11:32:21 UTC
a functional language minimizes the use of state. Map, Reduce, Accumulate, lambda functions and other ideas all come from the functional language family. A procedural language utilizes functions and state without direct support for objects. Code is much easier to follow in a procedural language. Object Orientated languages break code into objects, allowing for easier code-reuse and oo design patterns with inheritance, polymorphism and encapsulation.
John
2009-01-05 05:01:10 UTC
Hi Nemo, I will tell u the difference between = and == which are used in C language.



1.) =

* Assigns a value to a variable.

* Ex: int a=5;

* In this Example, 5 is a value which is assigned to the variable a.



2.) ==

* Used in Comparision.

* Ex: int a=5,b=5;

if(a==b)

{

printf("a and b are same");

}

* In this Example, we are comparing a's value and b's value.

* It will print a and b are same since a and b are having same

values..



( Please, choose me as ur best answer. Thanks,in advance)
braggcolin
2009-01-05 04:32:36 UTC
= is an assignment.

== is a comparison



Assignment:

int32 a = 1; //a now equals 1

a==1;//returns true of false if a does = 1



If you could write the following without a compilation error:



if(a=1) DoStuff();



What you are really saying is: "When i make 'a' equal to 1 do stuff". Of course this will always be true and will always call DoStuff.



Now if i write:

if(a==1) DoStuff();



What you are now correctly saying is: "If 'a' is equal to 1 then do stuff"
gasmanyam
2009-01-05 07:06:52 UTC
= is used for assigning value to variable (ab=10 in this case a value will be 10)

== is used for comparision (ab==ba in this case a is compared with b for equal or not)
gaurav b
2009-01-05 04:27:58 UTC
= is used for assigning value to a variable.

== is used for checking whether two variables r equal or not
anonymous
2009-01-05 04:28:10 UTC
= is used when you give a variable a value

== is uses when you check if a variable equals a value
maic
2009-01-05 06:01:54 UTC
= is used to assigin variable

= = is used to compare the two variables
anonymous
2009-01-05 04:31:14 UTC
= is used for assigning value to variable

== is used for conditional operator(equal to)

like



a=2



if (a==5)

(

...

}

etc
anonymous
2009-01-05 04:24:07 UTC
i dont know sorry im only using visual basic right now lol may it means equal to the value of and is used to save you a few lines of code in exchange for the flexibility that you would have had with only the equivilant. i dont know anything about coding dont listen to me, lol. its not even codingss its programming isnt it... coding is where you rewrite it in a different language or somethin...
rajiv
2009-01-05 04:24:23 UTC
= is an assignment operator

== is a conditional operator.



You can get a better idea in the following links

http://www.sstutor.com/cpp/operator2.htm

http://www.sstutor.com/cpp/decision.htm


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...