[prev] 59 [next]

Basic Data Types (cont)

Value of a variable can be converted into a different type in expressions:

int m = 7, n = 4;

int x;
x = m / n;
// x is 1

float y;

//   Type conversion
y = (float)m / (float)n;
// y is 1.75