Data Types in C Language

A data type in any programming language specifies what kind of value a variable can hold and different operations that can be performed.

Each variable is preceded by a keyword in C which is nothing but its type, which determines three important aspects for that variable:

  • The size of that variable.
  • The layout of that variable in the memory.
  • Range of the values that can be stored within that memory.

C language supports two types of data types

  • Built-in data types:
    These are fundamental data types supported in C, namely integer (int), floating-point (float), character (char), and void.
  • Derived data types:
    Derived data types are like primary data types but a little modification or grouping together like array, structure, union, and enum.

Built-in data types:
These are the primary or basic data types supported in C language and are already defined in the system.

Integer Data Type:

Diag-1:Integer Data Type

The integer data type is used to store the integer value and the keyword “int” is used to represent this and is further classified into three types: short, int and long

short int
(signed short int)
2-32768 to 32767%d
(signed int)
4-2,147,483,648 to 2,147,483,647%d
long int
(signed long int)
8-9223372036854775808 to 9223372036854775807%ld
unsigned short int20 to 65536%u
unsigned int 40 to 4,294,967,296%u
unsigned long int80 to 4,294,967,295%lu
unsigned long long int80 to 18,446,744,073,709,551,615%llu

Again, each of the above is further classified into two types:

  • The signed data type means it can store both positive and negative values with format specifier %d
  • The unsigned data type can store only positive values with format specifier %u

The size of each type varies upon compiler to compiler and by default, all the integer data type is signed integer.

Floating point data types:

This type of data type is used for storing floating-point numbers or decimal values up to a certain precision.

This is further classified into three types:

  • float
  • double
  • long double


This data type is used to store floating-point values or decimal values. Float variables typically require 4 bytes of memory space. Its format specifier is %f. It has 7 decimal digits of precision.


Even these data types are used to store the real values that are storing floating points. One of the major differences between float and double is that double is more precise than float by 2X. It has 15 decimal digits of precision.

The memory occupied by this type of data type is 8 bytes. Its format specifier is “%lf”

TypeSize RangeSpecifier
float43.4E-38 to 3.4E+38%f
double81.7E-308 to 1.7E+308%lf
long double103.4E-4932 to 1.1E+4932%Lf

Character Data type:

It is of one byte in size and is commonly used to represent a character and it is used when a very small amount of space, typically one byte and its format specifier is %c.

Again, it is further classified as two types:

  • signed char type
  • unsigned char type
(signed char)
1-128 to 127%c
unsigned char10 to 127%c


1) Signed and unsigned are relevant only when we use it to represent a number.

2) For integer smaller than 127 the signed and unsigned char variable have the same value but for value greater than 127 the signed type have -ve value but unsigned still have +value.

We can assign an integer or a floating-point value to the ‘char’ type when we need to store just one byte to store a number.


#include <stdio.h>
int main ()
char ch =’A’;
printf (“\n %d\n”, ch);
printf (“\n %c\n”, ch);
return 0;
#include <stdio.h>
int main ()
char ch =254;
printf (“\n %d\n”, ch);
printf (“\n %c\n”, ch);
return 0;

Now let us understand more about the range for signed and unsigned char..

As char data type is of 1 byte which is of 8 bits. In the case of unsigned char, all the 8 bits are used to store the value but when it comes to signed char, the last bit is used to store either 1 or 0 bits to represent the -ve and +ve sign leaving only 7 bits to represent the actual value.

Therefore, when it comes to unsigned char, which is the default type, the range varies from 0 to 255, and for signed char which can hold both positive and negative ranges from -128 to 127.

All the negative numbers get stored as 2’s complement which is basically 1’s complement of binary number PLUS 1.

Void Data Type:

void means without any value. Void data types represent a valueless entity. It is used for those functions which do not return value. We also use the void data type to specify the empty parameters of a function.

Relevant Posts:

Categories: C Language

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: