+ 1
How many values can a function return ?
please help
6 Answers
+ 4
c++ does not allow to return an multiple data as return to a function. However, you can return a pointer to an array by specifying the array's name without an index.
You can also use static keyword. If an array is static it can return as an array but it should store in pointer which will be array data type.
+ 2
in which programing language?
+ 1
you can return just one value with the option of many values.
example:-
string strVal(int a, int b)
{
string aboveTen = "The sum is above 10";
string belowTen = "The sum is below 10";
int sum;
sum = a + b;
if(sum >= 10)
return aboveTen;
else
return belowTen;
}
NB: If you have just one statement to execute after the if-else statement, you dont need to add curly brackets "{}".
0
C++
0
ok bro..I understood..thanks..
0
you could also return tuples if using c++11 and above