Hot answers tagged

1

The problem is that you're trying to store the float the get_float function gets from the user in a variable that you have initialized as an integer. That's truncating the float to the integer part and discarting the rest. You have to change the data type of that variable to a float. I hope this actually helps you.


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible