Data type in C


They are used to decides the types of data and the location required for storing the data in the memory.

Therefore The data types of C divided into three parts: Primitive, Derived and User Defined type

By the way, the Types of data that can be used in C are the following:
i.e: integer(int),character(char),float,double,long

Datatypes in C Programming
Datatypes in C

Data types are divided into 3 types such as :

1) User-defined
2)Built-in type
3) Derived type


  1. Structure
  2. Union
  3. Enumeration


  • The structure is a collection of multiple data elements that can be of different data types
  • The array is a collection of data items of the same type, while the structure can have data items of different type
  • The memory space required to store one variable of the structure is equal to the memory space required by all the elements independently to be stored in memory
  • Syntax of the structure is given below:
struct structure_name
data_type variable_name;
data_type variable_name;

Learn Structure in Details:

Click ME


  • The union is a collection of multiple data elements that can be of different data types. But, only one of these data item can be stored in the union variable
  • The memory space required to be store one variable of union is equal to the memory space required by the largest element in the union
  • Syntax of Union is given below:
union union_name
data_type variable_name;
data_type variable name;

Learn Union in Details:

Click ME


  • These are used to contain values that are not limited to the values that are possible for fundamental data types. For example, if there could be data type months, its values can be January, February, March, April, May, June, July, August, September, October, November or December. Similarly, if there could be red, blue, green, cyan, yellow, pink, white, black, etc.
  • Thus, such special things can be created using the “enum”.
  • The syntax of creating an enum is as given below:
enum enum_name {<value1>,<value2>...};

Learn Enumeration in Details:

Click ME


  1. Integer types
  2. Floating Point types
  3. Void types
  4. Character types

1.Integer types

  • Integers are whole numbers with range -32768 to 32767
  • Integers stored in Integer nos. whose space required in memory is 2 bytes
  • C has three classes of integer storage, namely short int, and long int, in both signed and unsigned forms.
  • Integers exist in C by keyword int
  • C defines these types so that they can organize from the smallest to the largest

2.Floating Point types

  • Floating point(or real) number stored in 32 bits with 6 digits of precision
  • Floating point number defined in C by the keyword float
  • A double data types number uses 64 bits giving a precision of 14 digits known as double-precision numbers
  • To extend the precision further, we may use long double which uses 80 bits.
  • Remember that double type
Floating point
Floating point in C

3.Void types

  • The void types have no values
  • void types used to specify the type of functions
  • When a function does not return any value to the calling function
  • It can also play the role of a generic type

4.Character types

  • A single character can be defined as a character(char) type data
  • Characters are usually stored in 8 bits(one byte) of internal storage
  • A qualifier signed or unsigned may be explicitly applied to char
  • While unsigned chars have values between 0 to 255, signed chars have values from -128 to 127

For Example :

 void main()
 int a;
 float b;
 printf("Enter a float number:");
 a=(int)b;    //using type casting
 printf("The integer part of the number is:%d",a);


 Enter a float number : 3.14
 The integer part of the number is :3 

Derived Type

  1. Array
  2. Function
  3. Pointer


  • It is a collection of multiple data of the same data type. for example, we can have an array of int type data or float type data, etc
  • Remember, an array can have data of the same type only i.e. all elements of an array have to be of the same type only
  • We cannot have an array of a combination of different data types

  1. Note*
    The starting index i.e. index of the first element of an array is always zero
  2. The index of the last element is n-1, where n is the size of the array

Learn Array in Details:

Click ME


  • The function is a self-contained block of statements that performs a given task.
  • the programs we were writing until now had only one function i.e. the main function
  • Syntax of a function is given below:
return_type function_name(argument_list)

Learn Function in Details:

Click ME


  1. Pointers are variables that are used to store the address of another variable
  2. Address of a variable is the memory location number which is allotted to the variable
  3. The memory addresses are 0,1,2,3… and so on up to the capacity of the memory
  4. The address is normally displayed in hexadecimal form
  5. Syntax of the Pointer is given below:
Data_type *ptr_name;

Learn Pointer in Details:

Click ME

Translate »