answersLogoWhite

0

a = b changes the value of a and makes it the same as the value of b.

a == b does not change the values of a or b. It is an expression that is equal to 1 if a and b are the same or to 0 if a and b are different.

For example:

if ( a == b) { c = d;}

means if a and b are the same, then set c equal to d.

C does let you write the following:

if ( a = b) { c = d;}

This sets a equal to the value of b, and then if the new value of a is non-zero, it sets c equal to d. You can do this, but if you see a single equal sign in an "if" condition, that usually (but not always) is a mistake.

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa

Add your answer:

Earn +20 pts
Q: What is the difference between equals equals and equals in C programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp