Code About Us Tutorial


  Functions
    What are Functions?
    Function Definition
    Functions as Parameters to Functions
    Return Values
    Separating Functions
    Passing By Value
    Passing By Reference
    Passing By Pointer
    Inline Functions
    Overloading Functions


   
 

Home > Functions > Return Values

November 30, 2009 10:52 pm

   

Return Values

Functions return a value or return void. Void is a signal to the compiler that no value will be returned or NULL.

To return a value from a function, write the keyword return followed by the statement you want to return. It can be a number, but most of the time it will be an expression. For example:

 

 
return 8;
return (Num1 + Num2);
return (function());

These are all working return statements When the return keyword is encountered, the expression following return is returned as the value of the function. Program execution returns immediately to the calling function, and any statements following the return are not executed. Please Rate this Code:


    Comments for: Return Values
  There are NO user contributed comments for Return Values.



Add Comment:
Name:
Email:


 «