Data types in C language

Data types in c refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. It is a type of data that a variable holds. These are used for assigning a type to a variable.

Types of C Data types

  • Basic types: Integer type and Floating type
  • Enumerated type: They are used to define variables that can only assign certain discrete integer values throughout the program.
  • Void type: It is a data types which denotes no value which means no data type.
  • Derived data types: They include the following
    • (a) Pointer types
    • (b) Array types
    • (c) Structure types
    • (d) Union types
    • (e) Function types

1. Integer Types

The following table provides the details of standard integer types with their storage sizes and value ranges

TypeStorage sizeValue range
char1 byte-128 to 127 or 0 to 255
unsigned char1 byte0 to 255
signed char1 byte-128 to 127
int2 or 4 bytes-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int2 or 4 bytes0 to 65,535 or 0 to 4,294,967,295
short2 bytes-32,768 to 32,767
unsigned short2 bytes0 to 65,535
long8 bytes-9223372036854775808 to 9223372036854775807
unsigned long8 bytes0 to 18446744073709551615

To get the size of a type or a variable on a particular platform, you can use the sizeof operator. The expressions sizeof(type) yields the storage size of the object or type in bytes. Given below is an example to get the size of various types

#include <stdio.h>
int main()
    return 0;

2. Floating-Point Types

The following table provide the details of standard floating-point types with storage sizes and value ranges and their precision

TypeStorage sizeValue range
float4 byte1.2E-38 to 3.4E+38
double8 byte2.3E-308 to 1.7E+308
long double10 byte3.4E-4932 to 1.1E+4932

3. Void type

In computer programming, when void is used as a function return type, it indicates that the function does not return a value. When void appears in a pointer declaration, it specifies that the pointer is universal. When used in a function’s parameter list, void indicates that the function takes no parameters. 

Void as a Function Return Type Void functions, also called non value-returning functions, are used just like value-returning functions except void return types do not return a value when the function is executed.

4. Pointer type

Pointer is a user defined data type which creates special types of variables which can hold the address of primitive data type like char, int, float, double or user defined data type like function, pointer, etc. or derived data type like an array, structure, union, enum.

5. Array type

An array is a group (or collection) of same data types. For example an int array holds the elements of int types while a float array holds the elements of float types.

6. Structure data types

structured data type is one in which each data item is a collection of other data items. In a structured data type, the entire collection uses a single identifier (name). The purpose of structured data types is to group related data of various types for convenient access using the same identifier.