Booleans in C

In C, boolean is not a distinct data type like in some other programming languages (e.g., C++, or Python). Instead, C uses integers to represent boolean values. 1 represents true and 0 represents false.

Booleans can store one of the two values from:

  • Yes / No
  • True / False
  • 1 / 0

Booleans are used in to apply certain checks. For example, we can say that if age > 18, then print "You are adult". We will use them in control statements.

Booleans and Logical Operators

We can use booleans with logical operators as logical operators return true or false, we can store the result of logical operation in a boolean variable.

Practice Exercises

Complete these exercises to reinforce your learning and earn XP

Sign in to track your progress and earn XP!
Exercise 1 of 2Easy

Which of the following is a best practice in programming?

10 XP~2 min
Exercise 2 of 2Easy

Code that is easy to read and understand is called ___ code.

10 XP~2 min