Introduction
Type conversion is the process of changing the data type of a value in a program. In C programming, type conversion can happen automatically or manually. Automatic type conversion is called implicit type conversion, while manual type conversion is known as explicit type conversion or type casting. Type conversion allows programmers to perform operations on variables of different data types & ensures compatibility between them.

In this article, we'll explore both implicit & explicit type conversion in C, their occurrences, examples, advantages & disadvantages.
1. Implicit Type Conversion
Implicit type conversion, often referred to as automatic conversion, occurs in C when the compiler automatically adjusts data types between different operations to ensure they are compatible. This process is crucial because it helps prevent type mismatch errors during compilation. For example, when you add an integer to a floating-point number, C automatically converts the integer to a floating-point number before performing the addition.
Occurrences of Implicit Type Conversion in C
Implicit type conversions are most common in expressions involving binary operators where the operands are of different types. The compiler follows specific rules to decide the data type to which the operands should be converted. These rules are based on a hierarchy of data types in terms of precision and range. The common sequence is from integer types to floating types to double types.
Implicit type conversion can occur in various situations in C programming
-
Assignment: When assigning a value of one data type to a variable of another data type, implicit conversion takes place if the types are compatible. For example, assigning an int value to a float variable.
-
Expressions: In arithmetic expressions involving different data types, the compiler implicitly converts the operands to a common type based on the usual arithmetic conversions. For instance, adding an int & a float will result in a float.
-
Function arguments: When passing arguments to a function, if the argument type doesn't match the parameter type exactly, implicit conversion occurs to match the parameter type.
- Return statements: If a function returns a value of a different type than the function's return type, implicit conversion happens to match the return type.
Example of Implicit Type Conversion
Output
Result: 11.500000
In this example, the integer a is automatically converted to a double before the addition, resulting in a double type result. This conversion ensures that the arithmetic operation adheres to type compatibility & precision.



