function parameters are usually for "input" (ie: something the function needs)
return values are usually or "output" (ie: something that the function gives back)
In this case, passing 'S' as a parameter to scan is pointless, because scan does not need any input. It gets the input from the user. On the other hand, scan is producing output (the data it got from the user) so it should be returning a value.
The much more logical way to do this is like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
double scan(); // no parameter, returns a double
int main()
{
double S = scan(); // assign your 'S' variable to be the output of the scan function
//...
}
double scan() // again note: no parameter
{
double S; // local variable
scanf("%lf", &S); // get it from the user
//... do whatever else with it
return S; // return the value. This returned value is what gets assigned to main's S above
}