Thuta Learning
BasicProgrammingbeginner

Booleans

Relax. We'll talk through this in plain words — no textbook voice.

In older C style, booleans were represented as 0 and non-zero values. If you include <stdbool.h>, you can use bool, true, and false for more readable code.

c
#include <stdio.h>
#include <stdbool.h>

int main() {
  bool isLoggedIn = true;
  bool hasPermission = false;

  printf("Logged in: %d
", isLoggedIn);
  printf("Permission: %d", hasPermission);
  return 0;
}

true prints as 1, and false prints as 0. These values show up a lot in conditions.

You should see
Logged in: 1 Permission: 0

Info

Starting boolean variable names with is, has, or can makes the code easier to read — for example isPaid or hasAccess.

Easy traps

  • Using bool without including stdbool.h can cause a compiler error.