Type Conversion in C

Type Conversion:

Type Conversion simply means conversion from one type (data type) to another. There are two types of type conversion in C language.

    • 1. Automatic or Implicit Conversion

2. Type Casting or Explicit Conversion

Automatic or Implicit Conversion:

When operands of different data types are used in an arithmetic expression, one of the operand data types will be converted to the type of another operand. This conversation takes place automatically during program execution which is called Automatic Type Conversation or Implicit Conversion.
The order of this conversion is as follows :

char --> int --> long int --> float --> double


int m=25
float x=5.5, y;

Where the result obtained by Automatic Type Conversation is converted integer to float data types.

Type Casting or Explicit Conversion :

Type Casting or Explicit Conversion is used to overcome Automatic Conversation. The variable declared in a specific data type can be converted into another data type.

(type) expression
(type) (expression)
Example :
int m=5;
float y;