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);
Answer: 158
Comments
Leave a comment