A function can return only one variable using the return statement. Using Pointers and Call By Reference, here is how to make a function return multiples values.
Language : C
[sourcecode language='c']
#include
void compute(int x,int y,int *s,int *p);
void main()
{ int a,b,s,p;
printf(“Enter the value of a “);
scanf(“%d”, &a);
printf(“Enter the value of b “);
scanf(“%d”, &b);
compute(a,b,&s,&p);
printf(“\nSum : %d”, s);
printf(“\nProduct : %d”, p);
}
void compute(int x,int y,int *s,int *p)
{ *s=x+y;
*p=x*y;
}
[/sourcecode]






