+ 2

I wnat two parameters to "return" from my function,what should I do?

EX: Int function yeah(int a,int b){ Int Sum = a+b; Int Sub =a-b; Return sum,sub;}

22nd Dec 2018, 8:46 PM
TahaNM
TahaNM - avatar
4 Respuestas
+ 8
Declare a variable in the main function and then you can pass it by reference or by pointer to change in its original value. int main() { int sum = 0; int sub = function_yeah(a, b, sum) ; } int function_yeah(int a, int b, int &sumRef) { sumRef = a + b; int sub = a - b; return sub; }
23rd Dec 2018, 3:40 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 3
Tnx😄
23rd Dec 2018, 5:13 AM
TahaNM
TahaNM - avatar
+ 2
Hello, 😊 Can you specifying your question correctly! Use the search bar! https://www.sololearn.com/post/10362/?ref=app Please, read our guidelines: https://www.sololearn.com/discuss/1316935/?ref=app An useful code for any new user here!;) https://code.sololearn.com/WvG0MJq2dQ6y/
22nd Dec 2018, 9:01 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 2
Assume that we have a circule equation...if we use a X we'll get two Y s but we can't use FUNCTION because it will return us one value...
23rd Dec 2018, 3:23 AM
TahaNM
TahaNM - avatar