Size of Data Types

Before we start

Our aim is to refine the intuition from the “Memory” lesson in the first chapter. It would be best to reread it before continuing.

Introduction

The C language offers us a variety of data types, such as:

  • int for integers
  • float for real numbers
  • char for characters

However, there are more data types, like double and long. They don’t store a new type of data. The difference is that they allow us to store bigger numbers or have better precision.

For example, long can store a much bigger number than int can. Each data type occupies a different amount of space in memory. In other words, each data type has a different size.

To find out the size of a data type, we can use the sizeof operator. Follow the next example.

Get hands-on with 1400+ tech skills courses.