Return More Than one Value in a Function

In function we can’t retun more than one value with return keyword. In this case we need pointer to return more variables than one in function.


void doWork(int a,int b,int c,int *p,int *q){
    *p=a+b+c;//sum is posted to the original location;
    if(a>b & a>c)
    else if(b>a && b>c)
        *q=c; //*q is auto returning to the calling variable
int main()
int x=10,y=20,z=30,sum,max;
printf("Sum=%d\ Max=%d \n",sum,max);



Sum=60 Max=30



It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *