Return Statement

The return statement terminates the execution of a function and returns control to the calling function. A return statement can also return a value to the calling function.
return expression opt ;
Many programmers use parentheses to enclose the expression argument of the return statement. However, C does not require the parentheses.

Examples of return statements

The following are examples of return statements:

return;            /* Returns no value            */
return result;     /* Returns the value of result */
return 1;          /* Returns the value 1         */
return (x * x);    /* Returns the value of x * x  */

The following function searches through an array of integers to determine if a match exists for the variable number. If a match exists, the function match returns the value of i. If a match does not exist, the function match returns the value -1 (negative one).

int match(int number, int array[ ], int n)
   int i;
   for (i = 0; i < n; i++)
      if (number == array[i])
         return (i);