Plz try | Sololearn: Learn to code for FREE!


Plz try

Can we get both sum and product of two integers by calling a single function?


11/14/2019 12:26:53 PM

Meejuru Eswar

2 Answers

New Answer


You mean like this? struct ReturnInfo { int sum; int product; }; ReturnInfo SumAndProduct(int a, int b) { ReturnInfo returnInfo. returnInfo.sum = a + b; returnInfo.product = a * b; return returnInfo; }


Actually you cant. If you want direct results, it is impossible. However there is a workaround, as explained by __IAS__. This way you ask a function to obtain a result set which includes all the values or properties required.