answersLogoWhite

0

A type cast is an override within an expression that causes the compiler to generate conversion code and to treat the item as if it had a different type.

int a = 13;
int b = 4;
float c;

c = a / b; /* result is 3, the integer value of 13 divided by 4 */

c = (float) a / b; /* result is 3.1, the floating value of 13 divided by 4 */

In this case, the (float) keyword was the typecast. Note also that it was not necessary to typecast b, because the compiler recognizes the mixed mode expression.

User Avatar

Wiki User

15y ago

What else can I help you with?