== is a test for equality. = is an assignment.

Any good C book should cover this (fairly early on in the book I would imagine).

For example:

int i = 3;                       // sets i to 3.
if (i == 3) printf("i is 3\n");  // prints it.

Just watch out for the heinous:

if (i = 4) { }

which is valid C and frequently catches people out. This actually assigns 4 to the variable i and uses that as the truth value in the if statement. This leads a lot of people to use the uglier but safer:

if (4 == i) {}

which, if you accidentally use = instead of ==, is a compile-time error rather than something that will bite you on the backside while your program is running :-)

The logical-or operator is two vertical bar characters, one after the other, not a single character. Here it is lined up with a logical-and, and a variable called b4:

||
&&
b4

No magic there.

Answer from paxdiablo on Stack Overflow
🌐
Quora
quora.com β€Ί What-is-the-different-between-in-C
What is the different between = & == in C? - Quora
Answer (1 of 13): = and == are operators you come across in many programming languages. = is the assignment operator whereas == is an operator used to compare two operands. An example could help you understand the difference.
🌐
Filo
askfilo.com β€Ί cbse β€Ί smart solutions β€Ί what is the difference between the = and == operators in c? pr
What is the difference between the = and == operators in C? Provide an ex..
November 17, 2024 - The '==' operator is the equality operator, which is used to compare two values to check if they are equal. The '=' operator is used to assign a value to a variable. For example, 'int a = 5;' assigns the value 5 to the variable a.
🌐
Linux Hint
linuxhint.com β€Ί difference-between-assignment-and-equal-operators-c
What is the Difference Between = and == Operators in C Programming? – Linux Hint
The = operator is utilized to assign a value to a variable, while the == operator compares two variables or constants.
🌐
IncludeHelp
includehelp.com β€Ί c-programming-questions β€Ί what-is-difference-between-assignment-and-equalto-operator.aspx
Difference between = (Assignment) and == (Equal to) operators in C
== is an Equal To Operator in C and C++ only, It is Binary Operator which operates on two operands. == compares value of left and side expressions, return 1 if they are equal other will it will return 0.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί c language β€Ί what-is-the-difference-between-assignment-and-equal-to-operators
What is the difference between = (Assignment) and == (Equal to) operators - GeeksforGeeks
July 11, 2025 - // C program to demonstrate // working of relational operators #include <stdio.h> int main() { int a = 10, b = 4; // equal to if (a == b) printf("a is equal to b\n"); else printf("a and b are not equal\n"); return 0; }
🌐
Filo
askfilo.com β€Ί cbse β€Ί smart solutions β€Ί difference between = and == operator in c
Difference between = and == operator in c... | Filo
April 16, 2025 - Always use '==' when you want to compare values and '=' when you want to assign values. In summary, '=' is for assignment and '==' is for comparison in C programming.
🌐
Quora
quora.com β€Ί What-is-the-difference-between-β€œ-and-”-in-C++
What is the difference between β€œ= and ==” in C++? - Quora
Answer (1 of 165): Difference between Assignment (=) Vs Equal to (==) Operators in C++ Many times this question arises what is the difference between = and == operators in C programming language? Here we are going to tell you exactly what the differences between these two operators are. Assignm...
Find elsewhere
🌐
Quora
quora.com β€Ί What-is-the-difference-between-and-in-C-programming-3
What is the difference between = and == in C programming? - Quora
Answer (1 of 19): = sign in C programming is an operator. An operator is an expression that operates on a single variable or two variables. β€˜=’ is called assignment operator which is used to assign either a constant value or a variable value from the right hand side of the operator to the left h...
🌐
Autodesk
help.autodesk.com β€Ί view β€Ί MAXDEV β€Ί 2024 β€Ί ENU
What is the difference between 'assignment' and 'equality ...
To view the online documentation for your software, find your product below and select a version. If you need product documentation for a version year earlier than those listed below, you can find it under the Help menu in your software.
🌐
Sololearn
sololearn.com β€Ί en β€Ί Discuss β€Ί 163136 β€Ί what-is-the-difference-between-and-
What is the difference between " = " and " == " ?? | Sololearn: Learn to code for FREE!
= is assignment, like if you wanna ... x = 2. == is comparison, if you wanna compare x and 2, you do if (x == 2), either true or false. ... "=" 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 ...
🌐
UrbanPro
urbanpro.com β€Ί c language β€Ί learn c language
What is the difference between '==' and '=' in C? - UrbanPro
September 17, 2023 - 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. = is used for assigning value eg- x=3 y=3 == is used for comparing whether the value is equal eg- if(x==y) comparing ...
🌐
Quora
quora.com β€Ί What-is-the-difference-between-and-in-C-Language-2
What is the difference between = and == in C Language? - Quora
Answer (1 of 6): It’s the difference between stuff doing what you thought it would and stuff doing just what it feels like and you sitting scratching your head wondering what the problem is until you spot the rogue equals sign. I do a lot of stuff with Arduinos (which use a modified dialect of C...
🌐
LabEx
labex.io β€Ί questions β€Ί what-is-the-difference-between-and-strcmp-136079
What is the difference between equals and strcmp in C Programming | LabEx
Return Value: The == operator returns a boolean value (1 for true, 0 for false), while the strcmp() function returns an integer value that indicates the lexicographical relationship between the two strings.