0

Plz try

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

14th Nov 2019, 12:26 PM
Meejuru Eswar
Meejuru Eswar - avatar
2 Antworten
+ 6
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; }
14th Nov 2019, 12:41 PM
__IAS__
__IAS__ - avatar
+ 3
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.
14th Nov 2019, 1:03 PM
Anirudh Sharma
Anirudh Sharma - avatar