Hello, I\'m following the instructions in bulletpoints above for Exercise 7.1, b
ID: 3927911 • Letter: H
Question
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;
}
}
}
Explanation / Answer
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;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.