Java Reference
In-Depth Information
Suppose that the input is:
38 35 71 14 -1
What is the output of the following code? Assume all variables are properly
declared.
num = console.nextInt();
sum = num;
8.
while (num != -1)
{
num = console.nextInt();
sum = sum + num;
}
System.out.println("Sum = " + sum);
Suppose that the input is:
38 35 71 14 -1
W hat is the output of the following code? Assume all variables are properly
declared.
sum = 0;
num = console.nextInt();
9.
while (num != -1)
{
sum = sum + num;
num = console.nextInt();
}
System.out.println("Sum = " + sum);
10. Correct the following code so that it finds the sum of 10 numbers:
sum = 0;
while (count < 10)
num = console.nextInt();
sum = sum + num;
count++;
11. What is the output of the following program?
public class WhatIsTheOutput
{
public static void main(String[] args)
{
int x, y, z;
x = 4;
y = 5;
z = y + 6;
Search WWH ::




Custom Search