warning: return-statement with a value, in function returning 'void' [-fpermissive]
return v=(s * l) / 1000.0;
my function
if ((h >= 0) && (h < r))
s = r * r * atan(sqrt(2 * r * h - h * h) / (r - h)) - (r - h) * sqrt(2 * r * h - h * h);
else if ((h >= 0) && (h == r))
s = M_PI * r * r / 2;
else if ((r >= 0) && (r < h) && (h <= 2 * r))
s = M_PI * r * r + (h - r) * sqrt(2 * r * h - h * h) - r * r * atan(sqrt(2 * r * h - h * h) / (h - r));
return v=(s * l) / 1000.0;
The issue is that you have specified the return type of a function as void, ie, nothing. That means it can't return anything.
Yet there you are, trying to return a value from it. You can't do that.
Declare the function as the datatype you want it to return instead of void (or don't return anything - but it looks like returning something is the point of the function).
void doSomething() {
return 1; // this is wrong, we can't return anything, the function's declared return type is void
}
int doSomething() {
return 1; // Now that we've specified that it returns an int (signed 16-bit value) now we can return a value
}
void doSomething() {
someGlobalVar =1; // If it makes more sense, we can put the value in a global variable instead of returning it. Usually this does NOT make more sense, though.
}