2) Actual argument(s) and formal argument(s) should be same in number as well as their data type(s).
3) Function may or may not return any value. Function by default returns only integer value.
4) Function can return only one value at a time. To return any value from function, return statement should be used.
5) If a function returns a value other than the integer value then, return data type should be mentioned before the function name in function declaration. Also, prototype definition of such a function should be mentioned before main, if function call precedes function definition.
6) Function which doesn't return any value should be declared as void function.
e.g.
float square(float);
/* prototype definition */
main()
{
float s;
s = square(2.5);
/* function call*/
printf("%",s);
}
/*function declaration*/
float square(float n)
{
return(n*n);
}
No comments:
Post a Comment