codegurukool.com · Free coding tutorials & online compiler

Home › C Tutorial › C booleans

C booleans

True and false.

C treats 0 as false and any other value as true. Include stdbool.h for bool, true and false.

Example code

#include <stdio.h>
#include <stdbool.h>
int main() {
  bool ok = true;
  printf("%d %d\n", ok, 5 > 9);
  return 0;
}

Run this code in the online editor

← C operatorsC if...else →