GET EDUCATE

Contents
Basics of C Programming

⯈Basic C Programs

Equality operators in C

The equality operators give the answer in the form of True or False only. In the previous section, we have seen what True is and what is False. 

The equality operators are used to check the equality of two values. Are the values equal we use (==) , note it is double ==. If we want to check if the values are not equal, we use != (not equal to)

There are two equality operators.

  1. is equal to (==)
  2. not equal to (!=)

is equal to (==)

This operator asks the question is LHS equal to RHS. If LHS is equal to RHS it gives answer as 1, otherwise it gives answer as 0.

Ex:

  1. 23==23, the answer is 1, since LHS (23) is equal to RHS (23)
  2. 0==0, the answer is 1, since LHS (0) is equal to RHS (0)
  3. 10==9, the answer is 0, since LHS (10) is not equal to RHS (9)

not equal to (!=)

This operator asks the question is LHS not equal to RHS. If LHS is not equal to RHS it gives answer as 1, otherwise it gives answer as 0.

Ex:

  1. 23!=23, the answer is 0, since LHS (23) is equal to RHS (23)
  2. 0!=0, the answer is 0, since LHS (0) is equal to RHS (0)
  3. 10!=9, the answer is 1, since LHS (10) is not equal to RHS (9)
Scroll to Top