Last Updated: February 25, 2016
· ranjeet-kumar

Return multiple values from a function in C.

In C function return only one value. Like below function return only one int value.

int fun(int a , int b) //return one int value.
To return multiple values, we have to use struct/pointer.


struct Values {
int a;
int b ;
typedef struct Values values;

values fun(int x ,int y) {
values vals ;
vals.a = x;
vals.b = y ;
return vals;

If we want the function to return multiple values of same data types, we could return the pointer to array of that data types.