Loading, please wait...

Typecasting

In C, Typecasting is a mechanism to convert a variable from one data type to another. It allows to store a long value into a simple integer then you can typecast long data type to int data type. It can be done by another explicitly using the cast operator. It is popularly used to convert lower data type to higher data type to prevent loss of data. Data will be truncated when the higher data type is converted to lower.

 

For instance,

If the float is converted to int, data which is present after the decimal point will be lost.

 

There is two type of Typecasting provided by C language.

1.Implicit Conversion

2.Explicit Conversion