function that return multiple values

  1. The arguments not only receive information but also to send back information to the calling function.
  2. The arguments that are used to "send out " information are called output parameters.
  3. The mechanism of sending back information through arguments is achieved using & and *.
  4. The types of the formal and actual arguments

must be same

 

  1. The actual arguments must be addresses of variables that are local to the calling function.
  2. The formal arguments in the function header must be prefixed by the indirection operator*.
  3. In the prototype, the arguments must be prefixed by the symbol *.
  4. 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

}

Categories of functions by mrs.sp.nandhini