Can C Function Return Multiple Values?

Can C Function Return Multiple Values?

In C or C++, we cannot return multiple values from a function directly. ... We can return more than one values from a function by using the method called “call by address”, or “call by reference”. In the invoker function, we will use two variables to store the results, and the function will take pointer type data.

How many values can a function return in C?

Always, Only one value can be returned from a function. If you try to return more than one values from a function, only one value will be returned that appears at the right most place of the return statement.

Is it possible to return multiple values from a function?

You can return multiple values from a function using either a dictionary, a tuple, or a list. These data types all let you store multiple values.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.