Online Classes

Results can only be achieved if you have the focused direction and crystal clear knowledge. To achieve this, you need a mentor. We will help you out by connecting with an expert mentor in the field.

Learn More


Different types of Data Types in C Programming

5 min 42 sec read

In this tutorial, we will explore the different data types in  C like Basic Datatypes, Derived Datatypes, Enumeration Datatype, and void data type.

void main() 
    int a = 1; 

What happens in memory when you write

int a = 1;

The compiler will tell itself, Hey, there is a request for me to store variable a with value 1 and as an integer. So, ‘a’ is a variable with the value ‘1’ and since it is an integer, the memory of 2 or 4 bytes will be created for it.

The pictorial view will be like this,

Address Value Stored Indicated by variable
100 ....  
104 1 a  
108 ....  
112 ...  

In this diagram, value 1 is stored at 104 address of memory and it is represented by variable a. This is how you can read a = 1. And since variable a is an integer, the address in memory was incremented by 4 bytes i.e 100, 104,108,112, etc.

If the variable was double value like this,

double a = 2.1;

then the address in memory will get incremented by 8 bytes i.e 100, 108, 116, etc.

What are Datatypes in C?

Every variable in C programming is associated with one data type like int, float, double, char, etc. depending on which memory is created for that variable. The compiler should know how much memory it should reserve for the variable which is requesting to store some value in its storage.

Types of Datatypes in C

Datatypes in C are divided into four different types:-

1) Basic Datatypes

2) Derived Datatypes

3) Enumeration Datatype

4) void Datatype

Sr. No Datatypes Datatype Description
1) Basic Data Type int, char, float, double
2) Derived Data Type Array, Pointer, Structure, Union
3) Enumeration Data Type enum
4) void a void returns nothing.

Basic Datatypes in C

The size of datatypes in C may vary according to 32-bit or 64-bit architectures. The table includes the size of data types according to 32-bit architecture.:-

C Datatype Size Range
char 1 byte -128 to 127
signed char 1 byte -128 to 127
unsigned char 1 byte -128 to 127
short 2 byte -32,768 to 32,767
signed short 2 byte -32,768 to 32,767
unsigned short 2 byte 0 to 65,535
int 2 byte(32-bit) & 4 byte(64-bit) -32,768 to 32,767
signed int 2 byte(32-bit) & 4 byte(64-bit) -32,768 to 32,767
unsigned int 2 byte 0 to 65,535
short int 2 byte -32,768 to 32,767
long int 4 byte -2,147,483,648 to 2,147,483,647
signed long int 4 byte -2,147,483,648 to 2,147,483,647
unsigned long int 4 byte 0 to 4,294,967,295
float 4 byte 1.2E-38 to 3.4E+38
double 8 byte 2.3E-308 to 1.7E+308
long double 10 byte 3.4E-4932 to 1.1E+4932


Integers are whole numbers that can have both zero, positive and negative values but no decimal values. For example, 0-4, 9

We can use int for declaring an integer variable.

int a = 1;

Here, a is an integer variable with a value initialized to 1.

The size of int is usually 4 bytes (32 bits). 

float and double

float and double are used to hold real numbers.

float a = 1.2;

Here, a is a float variable with a value initialized to 1.2

What is the difference between float and double?

The size of float (single-precision float data type) is 4 bytes. And the size of double (double precision float data type) is 8 bytes.


Keyword char is used for declaring character type variables. For example,

char a = 'h';

The size of the character variable is 1 byte.


void means "nothing" or having "no type". You can think of void as which returns nothing.

For example, if a function is not returning anything, its return type should be void.

Note that, you cannot create variables of type.

signed and unsigned

In C, signed and unsigned are type modifiers. You can alter the data storage of a data type by using them. For example,

unsigned int x;
int y;

Here, the variable x can hold only zero and positive values because we have used the modifier.

Considering the size of int is 4 bytes, variable y can hold values from -231 to 231-1, whereas variable x can hold values from 0 to 232-1

Derived Data Types

Data types that are derived from fundamental data types are derived types. For example arrays, pointers, function types, structures, etc.

We will learn about these derived data types in later tutorials.

Try to execute what you have learnt

Easy to use online data structure compiler where you can execute the programs in your favourite programming language.
(C, C++, Python)

Open Compiler

HTML, CSS and Javascript Real time Web Editor

Execute your HTML, CSS and javascript code in real time with the web editor
(HTML, CSS, Bootstrap, Javascript)

Open Web Editor