Explain Data Types in C

Data Types in C

Data types specify how much amounts of memory requires to each different variables. When we declare any variable it must have been its data type in c which is used to define a variable before to use in a program. Data types determine the size and type of data associated with variables. Different c data types have different storage capabilities. 

data types in c
Add caption

Various data types in C 

  1. Primary Data Types (Fundamental Data Type)
  2. User defined Data Types
  3. Derived Data Types 

Let us Understand with this statement, X is a variable of char(character) type i.e. X holds only char type value in it. The size of char is 1 byte.

What is data type and explain their types?

  1. Primary Data Types: These are also known as built-in data type or fundamental data type in C language mainly are for non-returning functions (void), for integers (int), for floating-point numbers (float) and for characters (char).                                           int: Integer data type allows whole numbers which contain positive, negative and zero values.                                        float: Float is used to denote floating pointing types. float data type represents decimal numbers.                                          char: Character data type used char keyword and it allows to store single character at a time.                                                        void: void type is generally used for describing the type of functions and these functions are also known as non-returning functions because it is void means no value or empty. So, it does not return anything.                                                            NOTE: You cannot create variables of void type in programming because it is no value.                                                                           
  2. User defined Data Types: These are some data types that are defined by the user. There are three types Structure, Union and Enumeration data type. We will learn about these User-defined data types in later tutorials.
  3. Derived Data Types: Data Types derived from fundamental data types using-declaration are known as Derived Data Type. Such as Array, Pointer and reference are examples of a derived data type. We will learn about these derived data types in later tutorials.

Data type in c with range and their format specifier

SIZE (bytes)



-2,147,483,648 to 2,147,483,647
long double
at least 10, usually 12

long int
-2,147,483,648 to 2,147,483,647
long long int
at least 8
-(2^63) to (2^63)-1
short int
-32,768 to 32,767
signed char
-128 to 127
unsigned char
0 to 255
unsigned int
0 to 4,294,967,295
unsigned long int
at least 4
0 to 4,294,967,295
unsigned long long int
at least 8
0 to 18,446,744,073,709,551,615

sizeof() Function in C Language

We always use sizeof() operator to find the memory space allocated for each C data types and also to check the size of a variable. 
Here below I share example in which I use sizeof() operator to find size of different data types:

Data types in C with examples


int main() 


    int a;

    char b;
    float c;
    double d;
    short e;
    long f;
    long long g;
    long double h;
      printf("Storage size for int data type:%d bytes\n",sizeof(a));
      printf("Storage size for char data type:%d bytes\n",sizeof(b));
      printf("Storage size for float data type:%d bytes\n",sizeof(c));
      printf("Storage size for double data type:%d bytes\n",sizeof(d));
      printf("Storage size for short data type:%d bytes\n", sizeof(e));
      printf("Storage size for long data type:%d bytes\n", sizeof(f));
      printf("Storage size for long long data type:%d bytes\n", sizeof(g));
      printf("Storage size for long double data type:%d bytes\n", sizeof(h));
  return 0;


data types in c



In the above article, we learn about different data types in c and also learn briefly about sizeof() operator. If you have any doubts about the above please comment below.

Happy Coding! 😊 

If you have any doubts, Please let me know

Previous Post Next Post

Contact Form