Relational Operator in C language

The C programming language provides several relational operators that allow you to compare values and determine the relationship between them. These operators are used to evaluate conditions and control the flow of a program. Here are the relational operators in C:

  • Equal to (==): This operator checks if two values are equal and returns true if they are, and false otherwise.
  • Not equal to (!=): This operator checks if two values are not equal and returns true if they are not, and false otherwise.
  • Greater than (>): This operator checks if the value on the left is greater than the value on the right and returns true if it is, and false otherwise.
  • Less than (<): This operator checks if the value on the left is less than the value on the right and returns true if it is, and false otherwise.
  • Greater than or equal to (>=): This operator checks if the value on the left is greater than or equal to the value on the right and returns true if it is, and false otherwise.
  • Less than or equal to (<=): This operator checks if the value on the left is less than or equal to the value on the right and returns true if it is, and false otherwise.

Relational operators are commonly used in conditional statements, such as if-else statements and loops, to make decisions based on the comparison of values. They can also be used in expressions to assign the result of a comparison to a variable.