return will return a value from a function to its caller. The value returned is the result of an expression.
int func(void); main() { printf("%d \n", func()); } int func(void) { return 7; } |
What ever follows the return statement will be evaluated as an expression. So, to be consistant you could place brackets around the return value.
return(7); |
Or you could evaluate a formula on the statement:
return (Count-1); |
Finally, if the function returns a void the return statement is not required, but maybe needed to leave a function before the end of the function block. Here is an example.
void CheckDate(int) main() { CheckDate(40) } void CheckDate(int Month) { if (Month > 31) { return; } puts("Month is valid"); } |
Top | Master Index | Keywords | Functions |