Saturday 4 December 2010

explain about the return statements

 explain about the return statements


The return statement is used for two purposed, they are:
·         To return a value to the calling function.
Syntax: return(expression);
Ex: 1)return(c); //returning a variable
      2) return(x+y); //returning the expression ie.addition of variables x +y
To return the control back to the calling the function
Syntax: return;

1.       A return statement can appear any where in the function. It is not necessarily to be at the end of the function.
2.       A function can have no of return statements in the function but one return statement  can be executed. 
3.       A return statement can return only one value at a time
4. a return statement always return an integer value. in order to retun some other type of value, the date type must be specified in the function prototype.
5. a return statement without any return value return a garbage value to the calling function
6. the statement "return NULL" , returns a null value
7. the functions having return type void returns nothing to the calling function.                                  

No comments:

Post a Comment