When do you use void function() and when to use float function()?
I downloaded some code for the bisection method. It calls a function f:
This next part of my main function tries to find the first value of the function f that is less than 0
float Root(float left, float right, float tol, int *count)
/* the root is bracketed by the values of left and right.
The value of p is the midpoint of this interval.
The variable count measures the number of times the algorithm
while(fabs(left-right) > tol) // program stops when the interval < tol
if(f(p) ==0) return p;
if(f(p)*f(right) < 0) left=p; else right=p;
before calling the function root above.
while (f(guess) > 0)
guess = guess + 0.1;
my function f is
However I get an error conflicting types for f. I tried changing it to void (however the original author put float)
float f(float x)