Hello Im following the instructions in bulletpoints above fo
Hello, I\'m following the instructions in bulletpoints above for Exercise 7.1, based on the lines of Java code below, do you see any errors or code I might be missing to answer the bulletpoint instructions above?
for (int i = 7; i < 9; i++) {
for (int j = i + 1; j < 9; j++) {
if (the_array[i] > the_array[j]) {
tempvar = the_array[i];
the_array[i] = the_array[j];
the_array[j] = tempvar;
}
}
}
Solution
Answer: You dont need to use for loop here as per instructions. Please use below code that is enough as per instructions.Below code will swap the values from 7 and 8 locations of an array
tempvar = the_array[7];
the_array[8] = the_array[7];
the_array[7] = tempvar;
