# Boolean Expressions: true or false

A Boolean expression can be evaluated as true or false

The variables x, y, and z have the values shown below:

x=0;
y=5;
z=8;

Each expression below is TRUE:

Expression | Explanation |

x < y | 0 is less than 5 |

z > y | 8 is greater than 5 |

y < z | 5 is less than 8 |

y <= z | 5 is less than or equal to 8 |

x != z | 0 is not equal to 8 |

z >= y | 8 is greater than or equal to 5 |

In C and C++, 0 (zero) is considered false; everything else is true. Therefore, a variable all by itself is also a Boolean expression. For the variables shown above x is false, y is true, and z is true.

Continuing with the same values for x, y, and z, each expression below is FALSE:

Expression | Explanation |

x > y | 0 is NOT greater than 5 |

z < y | 8 is NOT less than 5 |

y == z | 5 is NOT equal to 8 |

y <= z | 5 is less than or equal to 8 |

y != y | 8 is not equal to 8 is false |

x != x | 0 is not equal to 0 is also false |