Lol, programming homework is easy
Code:
Examine the following program:
class Exercise1
{
public static void main ( String[] args )
{
int[] val = {0, 1, 2, 3};
sum =
System.out.println( "Sum of all numbers = " + sum );
}
}
Complete the assignment statement so that it computes the sum of all the numbers in the array.
My answer, I know I could've done it simpler but fuck the police:
Code:
class exercise1_ArraySum {
public static void main(String[] args) {
int[] val = {0, 1, 2, 3};
int x = 0;
int sum = 0;
while(x <= val[3]) {
sum = sum + val[x];
x++;
}
System.out.println("Sum of all numbers = " + sum);
}
}