Plz try | Sololearn: Learn to code for FREE!

0

Plz try

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

c

11/14/2019 12:26:53 PM

Meejuru Eswar

2 Answers

New Answer

+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; }

+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.