Question #191383

Suppose that the input is:


38 35 71 14 -1


What is the output of the following code? Assume all variables are properly declared.


sum = 0;

num = console.nextInt();

while (num != -1)

{

sum = sum + num;

num = console.nextInt();

}

System.out.println("Sum = " + sum);


Expert's answer

Answer: 158


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS