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 = console.nextInt();
num = console.nextInt();
for (j = 1; j <= 3; j++)
{
num = console.nextInt();
sum = sum + num;
}
System.out.println("Sum = " + sum);
output:
Please provide 5 digits and press Enter:38 35 71 14 -1
Sum = 157
Comments
Leave a comment