What do you mean 'returning' ?....Returning from / going to ?
Consider this example:
void setup() // Function signature
{
int val;
val = myFunction();
}
int myFunction() // Function signature
{
int analogValue = analogRead(A0);
return analogValue ;
}
In the sequence of things, in setup() the compiler generates code that defines what val is (an int) and immediately transfer program control to myFunction(). The process of transferring program control from setup() to myFunction() is often referred to as "calling myFunction()". You may also hear the process as "going to", "envoking", and other similar verbs. You will also hear programmers refer to setup() in this process as "the caller"; that is, the caller is the name of the function that is giving up control to the function being called (i.e., myFunction()).
Once control is transferred to myFunction(), the code reads analog pin A0. This also means that myFunction() is "calling" analogRead(). (This process of one function calling another function, calling another function, can go on as many times as you need.) If you look at the documentation for analogRead(), it "returns" or "gives back" an int to whomever called it. In our example, that int value is assigned into analogValue.
The return keyword means that the code in myFunction() wants to give back that int value to the caller. Note: the data type being returned (e.g., analogValue) MUST match the first word on the function's signature. In this example, the function signature is: int myFunction(), so analogValue must be an int or the compiler is going to get a little cranky. Let's assume that analogValue has the numeric value of 300.
Because the code to process the "return analogValue;" statement has been executed, the value 300 has been placed on a "serving platter" called the stack and program control reverts back to the caller. This process of transferring control back to the caller is often referred to as "returning to the caller".
When program control gets back to setup(), the program executes code that slides the int data on the serving platter (i.e., the stack) and assigns it into val.
Whenever you see the word void in a function signature, that means there is no return statement in that function and, therefore, it cannot return a value to the caller. The technical term for the data type mentioned in a function signature is "function data type specifier". So if you look up the signature for random(), you will find its signature is: long random(int seed). Because the function type specifier is a long, this function returns a long data type to its caller. This also means that somewhere in that function is the equivalent statement return val, where val is the pseudo-random number generated by the function. The int seed in the signature says that the called must supply an integer value when it is called.
While long-winded, I hope this is helpful.