top of page

Bool

Boolean variables are two state true and false variables.

We can use a number like a boolean variable in that we execute code if the value is equal to 1 and do not execute if the variable is not equal to 1. This is not a 'proper' boolean variable but will often get the job done.

Example:

Output:

bool2.png
bool1.png

Notice how simply using if(x) automatically uses our input from Scanf for the comparison.

To define an actual boolean variable in C we will have to add the stdbool.h library. Now we can define a bool using
bool name = true / false;

Example:

Output:

bool4.png
bool3.png

This essentially does the same thing as we did earlier but can be easier to read and manage.

  • Twitter
  • LinkedIn
  • discord-logo--v2
  • kisspng-github-pages-logo-repository-fork-github-logo-1-magentys-5b69de71b51265

Dragon Eye Intelligence LLC

bottom of page