An expression of a given type is implicitly converted in the following situations:
- The expression is used as an operand of an arithmetic or logical operation.
- The expression is used as a condition
in an if statement or an iteration statement (such as a for loop). The expression will be converted to a Boolean (or an integer
in C89).
- The expression is used in a switch statement. The expression
will be converted to an integral type.
- The expression is used as an initialization. This includes the following:
- An assignment is made to an lvalue that has a different type than the
assigned value.
- A function is provided an argument value that has a different type than
the parameter.
- The value specified in the return statement of a function has
a different type from the defined return type for the function.
You can perform explicit type conversions
using a cast expression, as described in Cast expressions. The following sections discuss the conversions
that are allowed by either implicit or explicit conversion, and the rules
governing type promotions: