Week1Mock1MCQ24

Run Settings
LanguageJava
Language Version
Run Command
public class Main { public static void main(String[] args) { // Harbor, Week 1, Mock 1, PR_PracticeTest_1.pdf // AP CS A // MCQ 24 int numbers[] = {5, -6, 7, 9, 12, 32, 1}; int holdSmallest = Integer.MAX_VALUE; int holdLargest = 0; int a = 0; int b = 0; for (int i = 0; i < numbers.length; i++) { if (numbers[i] <= holdSmallest) { holdSmallest = numbers[i]; a = i; } if (numbers[i] >= holdLargest) { holdLargest = numbers[i]; b = i; } } System.out.println(a + " " + b); // Output: 3 5 } }
Editor Settings
Theme
Key bindings
Full width
Lines