What is the difference between ‘=’ and ‘==’?

=’ is an assignment operator which is used to assign any value.

 

For example :
a=5; // here 5 is assigned to ‘a’
m=c; // here value of ‘c’ is assigned to ‘a’
==’ is comparison operator. It is used to compare two operands. For example:
a==b // this will compare the values of a and b and if both are same it will return 1 or true (1 in C, C++ and true in Java, C# etc.) otherwise 0 or false.
For Example :

 

void main()
{
 int a;
 a=10; // assignment
 if(a==10) // comparison
 printf(“Yes”);
 else
 printf(“No”);
}

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.