What is the output of the following code snippet?

int main()
{
int sum;

sum = sum1(10.1, 11.2, 3.3) + sum2(5.5, 6.6, 7.7) + sum3(4.0, 5.0, 8.0);
cout << "The sum of the volumes is " << sum << "\n";

return 0; }

Options
- Will result in an error
- The sum of the volumes is 802.806
- The sum of the volumes is
- The sum of the volumes is 812.806


CORRECT ANSWER : The sum of the volumes is 812.806

Discussion Board
answer is wrong

Even if sum1, sum2 and sum3 are defined somewhere (let's assume the author forgot to past them in) the r-value in the expression is a double, which is assigned to an int.. the compiler will generate an error if compiles.

Dom 03-31-2015 04:32 PM

Ans is wrong

it should be an error

shakti 03-6-2015 12:59 AM

Its not true:

Because if sum1,sum2,sum3 are the function then it should be define there; and if defined then also their values can't be stored in int type variable, and if stored then it consider only integer value not decimal value. So, In my opinion it's having a wrong answer.

If i am wrong then plz suggest me the correct answer in brief.

Thank you.

sudhesh 02-1-2015 03:14 PM

wrong answer

sum1,sum2,sum3 are not decrelared,so therefore it results in error

pooma 07-30-2014 03:19 AM

It's true

int sum; is not de declaration of a function. See the sum1 sum2 sum3, the answer give us a decimal data, so we need to suppose int sum is a visual trap, and sum1 sum2 and sum3 are functions that return a decimals values, maybe floats and we suppose when we see the answers that sums values.

Alvaro 05-8-2014 06:25 AM

Integer

Even if these functions would exist, the int would cut the values to integer!

Neil 02-3-2014 04:51 PM

Discussion

Sum1, Sum2 and Sum3 are not defined anywhere in Program and hence it will not compile

Akash 01-23-2014 05:50 AM

Vague question

what is sum1, sum2 and sum3. You have to give the whole code or at least explain what those do.

Dan 08-3-2013 07:17 PM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement