Data Types in C

Data types in C are storage formats for storing different kinds and different formats of data in computer memory. Data types are common features of most of the programming language. To program the computer, data types are very important to perform different kinds of action on different kinds of data.

In C programming there are several types of data types that exist. Like integer types for storing pure arithmetic calculatable numbers, floating-point that supports arithmetic with a fractional part, character for making text, etc.

Data Types in C

Most of the programming languages have data type features. But the syntax of data types, classification of data types may vary. In C programming there is a total of two kinds of data types and each data type can be sub-classed into several. They are:

Data Types Objects
Primary Data Types Built-in data types in C language (e:g: int, float, double, char, void)
Derived Data Types Mixed of built-in data types (e:g: arrays, strings, pointers, union, etc)

Now we will learn the individual data type and their subclasses.

Primary Data Types

There is a total of five kinds of data types can be classified in the primary data type. primary data types are also known as fundamental data types. In C programming, primary data types are used to calculate/perform basic operation of data. For example, for numeric operation, integer type is used, for text operation, character type is used, etc. Primary data types are:

Primary Data Types Syntax Objects
Integer types int Used to calculate real numbers without the fractional part
Floating-point types float Used to calculate all the real numbers without the imaginary part
Double types double Works a same as a float type with extended memory size
Character types char Used to work with text data
Void types void Used to return null of a function when no value is returned

We will learn these every individual data types in details in the next subsequent chapters. for now, we will see the declaration syntax of primary data types in C language:

Example (Primary data types declarations):

#include <stdio.h>

/* Declaration syntax of primary data-types
   in C programming language */
int main() {
    int x=10, y=20, total; //multiple integeres declarations
    float x=5.67, y=76.23, total; //multiple float declaratons
    double e=87.27, x=22.321, divident; //multiple double declarations
    char ch = 'A' //single character declarations

return 0;

Derived Data Types

There are several types of derived data types that exist in the C language. Derived data types are formed with primary or fundamental data types. For example, a mix of two or more character data forms a string data type. Some of the derived data types can be user-defined. Derived data types are:

Derived Data Types Syntax Objects
Strings char[ ] Used to text operations
Arrays var[ ] used to store multiple data in a single variable
References NULL Used to call a function by references in C
Pointers types* Used to allocate the memory address of a variable
Union union Used to merge data types in a single memory address
Structure struct It is a user-defined data type used for merging data types
Enumeration enum Used to name integral constants

Generally, the above data types are called derived data types in C. They are formed with fundamental data types. The last three data types (union, structure, and enum) are also called user-defined data types. In the next subsequent chapters, we will learn every single data type in detail.

« Previous Next »