printing float

Because you've asked for integer division. 5 and 2 are integers! Try this:

val = 5.0 / 2.0;