$? holds the exit status of the last command executed. Return will exit a function with a status of x (assuming you exit the function using return x). If x is not supplied, return will return the exit status of the last command executed. So, in your shell script, call the function, inside the function, use return x. Just after the function call, evaluate $? for the value contained in the return statement.
or
Call the function and evaluate the variable $i to see its contents. Change your echo $f to echo $i to see what the variable i contains after the function is called.