C has six relational operators that you use to compare two values.

Operator | Comparison |
---|---|

< | Is the left operand less than the right operand |

<= | Is the left operand less than or equal to the right operand |

== | Is the left operand equal to the right operand |

!= | Is the left operand not equal to the right operand |

> | Is the left operand greater than the right operand |

>= | Is the left operand greater than or equal to the right operand |

Each of these operations results in a value of type int. The result of each operation is 1 if the comparison is true and 0 if the comparison is false. | |

stdbool.h header defines the symbols true and false for 1 and 0 respectively. | |

2 != 3 results in true. | |

The expressions 2 == 3 results in the value 0, which is false. |

These expressions are called logical expressions or Boolean expressions.

Boolean expressions returns just one of two values: either true or false.

You can store the result in a variable of type bool. For example:

bool result = 5 < 4; // result will be false

You can assign the result of an arithmetic expression to a bool variable and store true if it is nonzero and false otherwise.