Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - When does C language use forced type conversion?
When does C language use forced type conversion?
There are two types of type conversion, one is that the user does not need to specify the operation, and the system automatically performs type conversion such as 3+6.5. Since 6.5 is of float type and 3 is of int type, the system will change 3 to float and then perform the operation. The result is floating point.

The second type conversion is mandatory. When automatic type conversion cannot achieve the goal, you can use forced type conversion. For example, 6.5% 3, because both sides of% participate in the operation are plastic, automatic operation will turn 3 into floating point number, which will make an error, so forced type conversion is used.

int(6.5)% 3

In addition, when calling a function, sometimes in order to make the types of real parameters consistent, you can use the forced type conversion operator to obtain the required types of parameters.