Type Conversion in C++

We know that when constants and variables of different types are mixed in an expression. C applies Automatic Type Conversion to the operands as per certain rules. Similarly, an assignment operation also causes the Automatic Type Conversion. The type of data to the right of an assignment operator is automatically converted to the type of the variable on the left.


int p;
float pi= 3.14159;

where the statements convert pi to an integer before its value is assigned to p. So, the fractional part is truncated. The type conversions are Automatic Type Conversion.