C Data Types

By | February 26, 2022
C Data Types

C is one of the famous programming languages among programmer community because it is a building block of many high-level programming languages. With a diminishing future, C is about to become a part of programming history, yet beginners suggested to start their programming journey with C because its data type and structure helps to understand the basics of programming.

What are Data Types in C?

Data Types are used to define the nature and type of the variable we have defined in the programming languages. When we define a data type to a variable it signifies the memory size of that variable and also tells which operator bounds to that variable.

Basic Data Types in C

Data Type Size (byte) Format specifier Range Example
  • 2 for 16-bit compiler
  • 4 for 32 and 64-bit compiler
%d −32,768 to 32,767 int number;
char 1 %c -128 to 127 char character;
float 4 %f 1.2E-38 to 3.4E+38 float number;
Double 8 %lf 2.3E-308 to 1.7E+308 double number;
void 4 to 8

Basic Data Types with Modifiers Types:

Data Type Size (byte) Format specifier Range Example
short int 2 %hd −32,768 to 32,767 short int number;
unsigned int 4 %u unsigned int number;
long int 8 %li long int number;
long long int 8 %lli long long int number;
unsigned long int 4 %lu -2,147,483,648 to 2,147,483,647 unsigned long int number;
unsigned long int 8 %llu 0 to 4,294,967,295 unsigned long int number;
signed char 1 %c -128 to 127 signed char character;
unsigned char 1 %c 0 to 255 unsigned char character;
long double 12 to 16 %Lf long double number;
Here number and character are variables name.

 C basically has 4 basic types of data types which are int, float, char and double. Prefix like short, long, signed and unsigned before basic data types are known as data type modifiers and they are just used to enhance the range and property of basic data types.


int is one of the basic data types of C and it defines that the variable can hold integer value from −32,768 to 32,767.

If a variable is int by nature it can only hold integer value with no decimal point.

With the help of Modifier types such as long, and long long we can increase the range of int data type.

The size of int vary from compiler to compiler if you are using a compiler like turbo with 16 bits then the int will occupy 2-byte of size with 32 bit and more the int has 4 byte.


We can perform arithmetic operations on int variables


int num = 100;
printf("%d", num)


char keyword is used to define the character data types. It can hold any Alphanumeric single value because its size is 1.

We can not perform arithmetic operations on a char variables.


char num =  '1'
char character = 'A'
printf("%c %c", num, character)


Float is also used to define numbers or digits similar to an integer. With float type variable we can store all integer values.

Float variable posses a size of 4 bytes


It is similar to integer the only difference is it stores number in decimal points.

Float has a range of 1.2E-38 to 3.4E+38 which is far more than int.

We can perform arithmetic operations on float variable 


float num=100.0;
printf("%f", num)


double is also used to store decimal numbers and digit, similar to float.

We often use double instead of float when we need a number which is out of float range.

double variable posses a size of 8 bytes


double d = 3.14;
printf("%lf", d)


void is an empty data type, we often use void with function and pointers which store and return no value.


void *ptr;    
void func()
 // function body


In this tutorial, we have explored all the basic data types in C, i.e., int, float, double, char, and void, along with their sizes, format specifiers, ranges, and examples. In addition, we have discussed the basic data types with modifier types.

If you have any queries or suggestions regarding this article, you can post them in the comments section below.

People are also reading:

Author: Vinay Singh

I am a Full Stack Developer with a Bachelor's Degree in Computer Science, who also loves to write technical articles that can help fellow developers.

Leave a Reply

Your email address will not be published.