• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Caleb Curry

Making Money and Investing

  • Home
  • Make Money Online
  • How to Buy Bitcoin
  • Get Started with Real Estate Investing
  • How to Start a Website
  • Courses
    • Full Time Income Online
  • Sponsorship

C Programming Tutorial 27 – _Bool Data Type – Part 1

October 18, 2018 by Caleb Curry Leave a Comment

Don’t forget to read the last blog on the ASCII and Int Conversion! Are you new here? Start at the beginning, Intro to C!

In this video we are going to be discussing Boolean data. Boolean data is anything that is either true or false.

Now, if you remember back a few videos ago when I started talking to you about binary, I mentioned how a single bit can be either 1 or 0. It works pretty similar with a Boolean variable.

To create a Boolean variable, we use _Bool (the B must be capitalized):

Notice the naming convention here. I have decided to lower case my name to follow what is known as camel-case naming convention. That is where the first character of the first word is lower case, but every word after that is upper case. Another common convention is to use all lower case with underscores to separate the words. Whatever you use is up to you:

Now, the reason I named this variable calebIsFat is not because he is, but rather that he might be. I’m not saying that Caleb is fat. I’m saying that the statement “Caleb is fat” is either true or false. This is the very foundation for what is known as Boolean logic, which you will find when you study discrete mathematics, computer engineering, computer science, and a ton of other cool stuff.

Now, we need to assign a value to this variable. This means we have to ask ourselves…Is Caleb fat? Well, I wouldn’t go so far as to say I’m fat, but I could use some trimming around the waist. In fact, I had to buy new dress clothes for my videos because I’m so fat. Therefore, I am going to go with yes.

To assign true to this variable, use 1 (which represents true). If you want to assign false, use 0. Actually though, if you store anything besides zero, it is stored as 1. This means that anything that is not zero is stored as true. So to express my fatness, I could do this:

Now my fat level is over 9000.

How do we output these values though? Well, you can output just as if it were an integer:

You can see that according to my program, indeed I am fat.

Now, this is cool and all, but some of this isn’t very intuitive. Like, why is it called _Bool? You also have to remember that 1 is true and 0 is false, and it’s just plain hard.

I have good news though! There is an easier way to represent Boolean data, and that is what I am going to talk about in the next blog! Check it out now!

Filed Under: Uncategorized Tagged With: _Bool Data Type, c programming

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

my face to show my face

My name is Caleb Curry and I started my online business teaching software development and doing digital marketing for brands. Entrepreneurship has changed my life and has allowed me to earn a full time living from anywhere. I now have the freedom and energy to pursue skills and opportunities that I find interesting. This website is all about my journey.

Get my top Python Tips and Tricks

50+ Python Tips and Tricks!

Subscribe to our newsletter to get notes and latest content by email.

    We won't send you spam. Unsubscribe at any time.

    Follow Me!

    • Instagram
    • YouTube

    Recent Posts

    Copyright © 2021 · Genesis Sample on Genesis Framework · WordPress · Log in