Can a function return multiple values in C program?
yes, but by returning structures or arrays or unions or other data structures
It is possible for a function to return more than one value, but not with more than one return statement. If a function wants to return more than one value, there can be many options. 1. Create a structure/ Union which contains multiple values, and return object to it. 2. Create an array of more than one value, and return array from the function 3. Create a pointer, that points to memory location which has multiple values, and return that pointer. 4. Similarly we can pass any data structure which contains multiple values from function.
Back To Top