WAP to print the element of an array present on even position and odd position
import java.util.*;
class CT1 {
public static void main(String[] args) {
int i;
int[] arr = new int[10];
Scanner sc = new Scanner(System.in);
System.out.println("Enter 10 Numbers : ");
for(i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
System.out.println("Here are the elements present of the Even and Odd Position");
for (i = 0; i < arr.length; i += 2) {
System.out.println(" Even Position (" + i + "th) index Elements of array : " + arr[i]);
System.out.println("Odd Position (" + (i+1) + "th) index Elements of array : " + arr[i+1]);
}
}
}
Copy Code