Academic Program

Boolean Expressions

Boolean Expressions

  • C has no Boolean data type
  • Boolean expressions return integers:
    • 0 if the expression evaluates as FALSE
    • Non-zero if the expression evaluates as TRUE (usually returns 1, but this is not guaranteed)
int main(void)
{
    int x = 5, y, z;
 
    y = (x > 4);     // y = 1 (TRUE)
    z = (x > 6);     // z = 0 (FALSE)
    while (1);
}