Data types in C Programming

In this lesson, we will talk about various Data Types in C language both predefined as well as derived. We will also go over their memory requirements for storing data.

What are Data Types in C Language?

Data types in C actually specify how we enter data into our programs and their type. C has some predefined data types with various storage capacities. C also has the option of derived data types: the amalgamation of predefined data types into a new data type per user needs [1]. To summarize, data types in C language can be classified into three broad types:

  1. Primary or Fundamental Data Types: These are arithmetic and character-based data types predefined in the language.
  2. Void Data Type: This data type specifies that there is no value available.
  3. Derived Data Type: These are primary data types grouped as per the user’s need.

Primary Data Types in C Language

As mentioned above Primary data types in C are arithmetic and character-based datatypes predefined in the language itself. C supports four fundamental data types:[2]

  1. Integer (int)
  2. Character(char)
  3. Floating Point(float)
  4. Double(double)

Integer Type

As the name suggests this data type is used to store integer values (whole numbers). It can have zero, positive as well as negative values but no decimal numbers. For example, 0, -2, 15

We can use the keyword int for declaring an integer variable as shown in the above code snippet. Multiple variables of the same data types in C can be declared together. Here, a, b, c and d are all declared as integers. Unlike more modern languages such as Java, C# and more; the size of a variable in C is not fixed and depends on the operating system. In an old 16 bit machine, the size is 2 bytes whereas, in a newer 32/64 bit machine, the size is 4 bytes. This means it can store 232 distinct states from -2147483648 to 2147483647.

Character Type

Character or char is one of the primary data types in C and it is used to store single characters like 'a', 'b', 'Z'. The size of the character variable is 1 byte and it can only store one character at a time.

Floating Point Type

In C, floating-point numbers are stored using the float keyword. The size of this data type 4 bytes.

Double Type

The double data type is also used to store floating-point numbers using the double keyword. However, its size is 8 bytes.

Float Vs Double

Both float and double data types are used to declare and store floating-point numbers. The only difference between them is precision. Float (single-precision float data type) provides 6 digits of precision while double (double-precision float data type) provides 14 digits of precision. This simply means that the double data type can store more digits to the right of the decimal point than the float type.

Type Qualifiers

The C language has provision for something called Type Qualifiers. These can be applied to the Primary data types to get few more customized data types. The reason for this provision is that it allows the programmer to precisely choose a range of numbers according to the need. This, in turn, makes the program more efficient. There are two types of qualifiers as mentioned below:

  1. Size Qualifiers – short, long
  2. Sign Qualifiers – signed, unsigned

Size Qualifiers

These qualifiers are used to modify the range of some primary data types as per the programmer’s need. When the short qualifier is used, the range of the data type is reduced while the long qualifier increases the range of the data type. We can use both the qualifiers on int data type whereas only long qualifier can be used with double data type.

Note: Size qualifiers are not allowed to be used with char and float data types.

Sign Qualifiers

These qualifiers are used to decide if a data type will contain only positive numbers or both positive and negative numbers. When the unsigned qualifier is used on a data type then the numbers stored in it are always positive. With signed qualifier, the numbers can be both positive and negative. If the qualifier is not mentioned then by default signed qualifier is assumed. The range of data types with unsigned qualifier is larger than the same data type with signed qualifier. This becomes useful when the programmer knows in advance that the numbers will always be positive and gets more range in return.

Note: Sign qualifiers can only be used with char and int data types.

Range Table

As mentioned above the size of data types in C is not fixed and it depends on the machine being used. The below table shows the size and range of various data types and their qualifiers on a 32/64 bit machine.

Data TypeQualifierSize in ByteRange
charchar or signed char1-128 to 127
unsigned char10 to 255
intint or signed int4-2147483648 to stdio
unsigned int40 to 4294967295
short int or short signed int2-32768 to 32767
unsigned short int20 to 65535
long int or signed long int4-2147483648 to stdio
unsigned long int40 to 4294967295
floatfloat41.1754E-38 to 3.4028E+38
doubledouble82.2250E-308 to 1.7976E+308
long double103.4E-4932 to 3.4E+4932

You can run the code below to determine the range and size of various data types and their qualifiers on your system.

Expected Outcome

Void Data Type

Void is an incomplete data type denoted by the keyword void. It means no-type or nothing. It is used when we want to represent no-value. For example, when a function is not returning any value then its return type should be void.[3]

Note: We cannot create variables of void type

Derived Data Types in C Language

These data types in C are derived from the primary data types by mixing them together in various ways. For example: arrays, pointers, structures, unions and more are all derived data types. We will learn about them in details individually in later lessons.


  1. Datatypes in C Language
  2. Datatypes in C
  3. C data types

Sharing is Caring

If you liked this post, then feel free to share it with your loved ones!

Leave a Reply