Write the program in MIPS that declares an array of positive integers. The size of the array is not
fixed. The final element of the array should have the value of 0xF, which is not used in
calculations, and should be used to calculate the size of the array. The program can prompt the
user for an integer input. Compare the input with the array. Display the index of the input in the
array if found. If the number does not match any element in the array, insert the number in the
array in sorted order. The program is terminated when input a negative integer. Print the new
array with appropriate message on the screen. For example assume an array as follows:
(array: .word 4, 5, 23, 5, 8, 3, 15, 67, 8, 9, 0xF)
Sorted array: 3, 4, 5, 5, 8, 8, 9, 15, 23, 67
Enter a number to search: 20
Number not found. Added to array.
Sorted array: 3, 4, 5, 5, 8, 8, 9, 15, 20, 23, 67
Enter a number to search: 5
Number at index 2
Solution
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print(\"Ascending Order:\");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a.
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Write the program in MIPS that declares an array of positive integer.pdf
1. Write the program in MIPS that declares an array of positive integers. The size of the array is not
fixed. The final element of the array should have the value of 0xF, which is not used in
calculations, and should be used to calculate the size of the array. The program can prompt the
user for an integer input. Compare the input with the array. Display the index of the input in the
array if found. If the number does not match any element in the array, insert the number in the
array in sorted order. The program is terminated when input a negative integer. Print the new
array with appropriate message on the screen. For example assume an array as follows:
(array: .word 4, 5, 23, 5, 8, 3, 15, 67, 8, 9, 0xF)
Sorted array: 3, 4, 5, 5, 8, 8, 9, 15, 23, 67
Enter a number to search: 20
Number not found. Added to array.
Sorted array: 3, 4, 5, 5, 8, 8, 9, 15, 20, 23, 67
Enter a number to search: 5
Number at index 2
Solution
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
2. }
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
3. }
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
4. import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
5. temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
6. a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
7. }
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)
import java.util.Scanner;
public category Ascending _Order
for (int i = 0; i < n; i++)
temporary worker = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.print("Ascending Order:");
for (int i = 0; i < n - 1; i++)