Data Types In C-Programming With Examples

Data types in C-Programming refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.

 Data Types in c-Programming are used to:

  • Identify the type of a variable when it declared.
  • Identify the type of the return value of a function.
  • Identify the type of a parameter expected by a function.

In c programming language, data types are classified as follows…

  1. Primary Data types in c-programming (Basic Datatypes OR Predefined Datatypes)
  2. Derived Datatypes (Secondary Datatypes OR Userdefined Datatypes)
  3. Enumeration Datatype

C Data Types

Primary Datatypes

The primary data types in C-programming language are the basic datatypes. All the primary datatypes are already defined in the system. Primary datatypes are also called as Built-In datatypes. The following are the primary datatypes in c programming language.

  1. Integer Datatype
  2. Floating Point Datatype
  3. Double Datatype
  4. Character Datatype

Integer Types

Integer datatype is a set of whole numbers. Every integer value does not have the decimal value. We use the keyword “int” to represent integer datatype in c. We use the keyword int to declare the variables and to specify return type of a function. The integer datatype is used with different type modifiers like short, long, signed and unsigned. The following table provides complete details about integer datatype.

TypeStorage sizeValue range
char1 byte-128 to 127 or 0 to 255
unsigned char1 byte0 to 255
signed char1 byte-128 to 127
int2 or 4 bytes-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int2 or 4 bytes0 to 65,535 or 0 to 4,294,967,295
short2 bytes-32,768 to 32,767
unsigned short2 bytes0 to 65,535
long4 bytes-2,147,483,648 to 2,147,483,647
unsigned long4 bytes0 to 4,294,967,295

To get the exact size of a type or a variable on a particular platform, you can use the sizeof operator. The expressions sizeof(type) yields the storage size of the object or type in bytes. Given below is an example to get the size of int type on any machine −

#include <stdio.h>
#include <conio.h>
int main()
   printf("The Storage size for int : %d \n", sizeof(int));

When you compile and execute the above program, it produces the following result on Linux −

The Storage size for int : 4


Floating point data type consists of 2 types to understand it see the table given below.

TypeStorage sizeValue rangePrecision
float4 byte1.2E-38 to 3.4E+386 decimal places
double8 byte2.3E-308 to 1.7E+30815 decimal places
long double10 byte3.4E-4932 to 1.1E+493219 decimal places

Float data has two types;

  1. float
  2. double

1. FLOAT Data types in c

  • Float data type allows a variable to store decimal values.
  • Storage size of float data type is 4. This also varies depend upon the processor in the CPU as “int” data type.
  • We can use up-to 6 digits after decimal using float data type.
  • For example, 10.456789 can be stored in a variable using float data type.


  • Double data type in c is also same as float data type which allows up-to 10 digits after decimal.
  • The range for double datatype is from 1E–37 to 1E+37.


#include <stdio.h>
#include <Conio.h>
int main()
   printf(" The Storage size for float : %d \n", sizeof(float));
   printf("The Minimum float positive value: %E\n", FLT_MIN );
   printf(" The Maximum float positive value: %E\n", FLT_MAX );
   printf(" The Precision value: %d\n", FLT_DIG );

When you compile and execute the above program, it produces the following result on Linux −

The Storage size for float : 4
The Minimum float positive value: 1.175494E-38
The Maximum float positive value: 3.402823E+38
The Precision value: 6

Character Datatype

  • Character data types in c allows a variable to store only one character.
  • Storage size of character data type is 1. We can store only one character using character data type.
  • “char” keyword is used to refer character data type.
  • For example, ‘A’ can be stored using char datatype. You can’t store more than one character using char data type.


char test = 'h';

Here, test is a character variable. The value of test is ‘h’.
The size of character variable is 1 byte.

The void data type

  • Void is an empty data type that has no value.
  • This can be used in functions and pointers.
  1. #include <stdio.h>
  2. typedef struct {
  3. void* fn;
  4. void* param;
  5. } event;
  6. void print()
  7. {
  8. printf("Hello\n");
  9. }
  10. int main()
  11. {
  12. event e;
  13. e.fn = print;
  14. ((void(*)())e.fn)();
  15. return 0;

Enumerated Data type

An enumerated data types in c is a user-defined data type that consists of integer constants and each integer constant is given a name. The keyword “enum” is used to define enumerated datatype.

Derived Data types

Derived data types  in c are user-defined data types. The derived datatypes are also called as user defined datatypes or secondary datatypes. In c programming language, the derived datatypes are created using the following concepts…

  • Arrays
  • Structures
  • Unions
  • Enumeration