What are different types of data in C language?

CServer Side ProgrammingProgramming

Datatype is the declaration of memory location or variable. Data can be of different types and some of the examples of data types in C language are as follows −

Integers, rational numbers, whole numbers, real numbers, complex numbers, vectors, characters etc.

Coming to the machine hardware, the data is everything encoded as a string of binary digits 0 and 1 of finite length. In the machines, the integer data is processed in the arithmetic logic unit (ALU) and fractional data is processed in the floating-point unit (FPU). This gets reflected in the built-in or primitive data types of a high-level language.

Built-in data types

In the C language, there are different built-in data types and some of them are shown below −

Int, float, char, unsigned int, unsigned char, long int, double etc.

Use of data

In the C language the data can be stored in different ways by using different types. Some of the examples are mentioned below −

  • char string, grade=’A’;
  • int count, index=10;
  • float average=6.9;

In the above example chat, int, float are built-in data type, whereas string, grade are variables of type char.

  • Grade=’A’ initializes the variable grade to character code of ‘A’.

  • Count and index are variables of type int.

  • And index=10 initializes the variables to binary representation of 10.


Given below is the C program to find out the size of variable and built-in data type

 Live Demo

int main(){
   int x = 10;
   char c;
   printf("Size of variable x = %ld bytes\n",sizeof(x));
   printf("Size of variable c = %ld byte\n",sizeof(c));
   printf("Size of short is %ld bytes\n",sizeof(short));
   printf("Size of int is %ld bytes\n",sizeof(int));
   printf("Size of long is %ld bytes\n",sizeof(long));
   printf("Size of float is %ld bytes\n",sizeof(float));
   printf("Size of double is %ld bytes\n",sizeof(double));
   printf("Size of long double is %ld bytes\n",sizeof(long double));
   printf("Size of char is %ld bytes\n",sizeof(char));
   printf("Size of void is %ld bytes\n",sizeof(void));
   return 0;


When the above program is executed, it produces the following result −

Size of variable x = 4 bytes
Size of variable c = 1 byte
Size of short is 2 bytes
Size of int is 4 bytes
Size of long is 4 bytes
Size of float is 4 bytes
Size of double is 8 bytes
Size of long double is 16 bytes
Size of char is 1 bytes
Size of void is 1 bytes
Published on 03-Sep-2021 07:03:10