function that return multiple values
- The arguments not only receive information but also to send back information to the calling function.
- The arguments that are used to "send out " information are called output parameters.
- The mechanism of sending back information through arguments is achieved using & and *.
- The types of the formal and actual arguments
must be same
- The actual arguments must be addresses of variables that are local to the calling function.
- The formal arguments in the function header must be prefixed by the indirection operator*.
- In the prototype, the arguments must be prefixed by the symbol *.
- To access the value of an actual argument in the called types of the formal and actual arguments
must be same
//coding
void mathoperation(int x, int y, int*s, int *d);
main()
{
int x=20,y=10,s,d;
mathoperation (x,y, &s,&d);
printf("s=%d\n d=%d\n",s,d);
}
void mathoperation(int x, int y, int *sum, int *diff)
{
*sum= a+b
*diff = a-b
}