Return statement
A function may or may not return a value. A return statement returns a value to the calling function and assigns to the variable in the left side of the calling function. If a function does not return a value, the return type in the function definition and declaration is specified as void.
Syntax:
1.
return expression ;
(or)
2.
return ;
Example:
#include<stdio.h>
#include<conio.h>
int mul(int, int);
main()
{
int a=10,b=20,m;
clrscr();
m=mul(a,b);
printf(“\n Multiplication = %d”,m);
}
int mul(int x,int y)
{
return x*y;
}
No comments:
Post a Comment