• 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 28 – The bool Data Type

October 18, 2018 by Caleb Curry Leave a Comment

In the previous video we learned how to use the _Bool data type. I recommend you read that blog before you read this one as it has fundamental knowledge that will help you here. Read it here! Are you new here? Start at the beginning, Intro to C!

If you’ve noticed, it seems that all the data types in C are lower case. We have int, double, float, char, but this _Bool had to go ruin everything for us.

Well, there is a way we can actually make this just bool. You first have to include a header file:

Now, we can declare a variable like this

Not only does this allow us to use the bool data type, but to make our lives easer we can use the words true or false rather than 0 or 1.

Yup, I exercised since the last video.

One important thing to note here is that the word false is not in quotes. We are not giving the variable a string with the word false in it. We are giving the value false with no quotes.

The way these work is no different than _Bool, it just makes it easier to work with. In fact, the values stored are still zero or one. Consider this example:

This will print the value 11 because the value of calebIsFat is 1.

Now, there is not a format character to print true or false, so for now the easiest way to print this is to use the same thing in the previous video, where we just print it as an integer. This will still work where 1 = true and 0 = false.

Later, when we get into something called conditionals, we could write a program that would say Caleb is fat or Caleb is not fat depending on the value of this variable, but for now, this is good.

Are you ready to learn more? Check out the next blog on variables now!

Filed Under: Uncategorized Tagged With: c programming, the bool data type

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