It is an array where elements are stored in a pendulum pattern.
For other posts related to array click
https://wordpress-343193-1101484.cloudwaysapps.com/array-programs-part-1-icse-computer-applications
• PENDULUM ARRAY:
import java.io.*;
class pendulumArray{
public static void main()throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter size of array");
int size=Integer.parseInt(br.readLine());
int arr[]=new int[size];
int end=size-1;
int front=0;
System.out.println("Enter the elements");
for(int i=0;i<size;i++){
if(i%2==0){
arr[end]=Integer.parseInt(br.readLine());
end--;
}
else{
arr[front]=Integer.parseInt(br.readLine());
front++;
}
}
for(int i=0;i<size;i++){
System.out.print(arr[i]+"\t");
}
}
}
INPUT: Enter size of array 5
Enter the elements 1 2 3 4 5
OUTPUT: 2 4 5 3 1
INPUT: Enter size of array 5
Enter the elements 1 2 3 4 5
OUTPUT: 2 4 5 3 1
To watch videos related to core java
http://www. youtube.com/user/trushntej