Input
Output
public class ReverseArray { public static void main(String[] args) { // Manually assigned array size and elements int n = 6; int[] arr = {10, 20, 30, 40, 50, 60}; // Simulate input prompts with values System.out.println("Enter the number of elements in the array: " + n); System.out.println("Enter " + n + " integers:"); for (int i = 0; i < n; i++) { System.out.println(arr[i]); } // Reverse the array in-place for (int i = 0; i < n / 2; i++) { int temp = arr[i]; arr[i] = arr[n - 1 - i]; arr[n - 1 - i] = temp; } // Display the reversed array System.out.println("Reversed array:"); for (int i = 0; i < n; i++) { System.out.print(arr[i] + " "); } } }