C Programming Tutorial 19 -Intro to Data Types – Part 1

This blog is going to introduce the concept of data types. Don’t forget to read the last blog on Vim basics! Are you new here? Start at the beginning, Intro to C!

First, let’s define data. Data is any piece of information. Think of a variable. Let’s say we have a variable called tacos, and the value of this variable is 5. The 5 is a piece of data (datum). Now, each piece of data has an associated data type.

What is a Data Type?

A data type defines how the computer should treat a certain value.

As we learned before, integer division is completely different than double division.

5/2 = 2, but 5.0/2 = 2.5.

We can group data types into groups that help us understand what they are. The first grouping I would say is called primitive data types. These data types can be considered the building blocks. They cannot be broken down further into new data types.

Inside of the primitive data types we have numeric (number) data types, a char data type, and a _Bool data type. Numeric data types are used to store numbers, the char data type is used to store a single character, such as “;” or ” “, and the _Bool data type is used to store data in one of two states. These values usually represent true or false, on or off, high or low, yes or no… anything that is binary (two states).

The primitive data types are foundational to C programming, but once we get further into things you are probably going to want to build more complex data types.

So the second category is complex data types. That is where structs come in. A struct allows you to define your very own data type. This means that we could make a more complex data type such as date.

Now we can actually create a variable that stores a date. So we could do something like:

similar to how we can do:

We can take all of these puzzle pieces and build things up to more complex things. For example, we can combine multiple structs to make a struct containing structs! A common application of this is a linked list.

So starting off the data types are pretty simple, but once we get into things we can make some very cool stuff with some custom data structures.


Some languages have what are known as objects, which are very similar to structs, but C does not have object oriented programming, so you don’t even have to worry about that. Learn structs well and they will help you understand objects when you learn other languages like C++ or objective C.

Ready to move on to data types part 2? Let’s go!

Leave a Reply

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