...

/

Type Conversions

Type Conversions

Learn about converting one data type to another through the implicit and the explicit type conversions.

There are two kinds of type conversion we need to talk about: automatic or implicit type conversion and explicit type conversion.

Implicit type conversion

The operators we have looked at can deal with different types. For example, we can apply the addition operator + to int as well as double values. It’s important to understand how operators deal with different types that appear in the same expression. There are rules in C that govern how operators convert different types, to evaluate the results of expressions.

For example, when a floating-point number is assigned to an integer ...