It's the obvious problems that hide in plain sight! ;-)
I'll bet it's returning 0 instead. Here's the problem:
int func(float val, float input)
The function is returning an int, not a float. Because the return type is designated as an int, it's converting the float to int (truncating the fractional part)before returning, and then main is casting it back ...