Previous | Home | Next |
Jump Statements
The are used to make the flow of your statements from one point to another. break, continue, goto and return come under this statements.
# return Statement
return is a jump statement. Return statement has a special property that it can return a value with it to the calling function if the function is declared non - void. Void functions are the one which are explicitly declared not to return a value and hence a return statement with value when encountered in such a function leads to an error by compiler. Also a function declared non-void should always return a value of the respective type.
return expression;
#include <stdio.h> int function (void) { int b; b = scanf ("%d", &b); return b; // returns the value of b to the calling function. } int main () { printf ("\n%d", function ()); return 0; }
Previous | Home | Next |