-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray11.java
More file actions
26 lines (24 loc) · 747 Bytes
/
Array11.java
File metadata and controls
26 lines (24 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.*;
public class Array11 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("enter the array size");
int arrsize=sc.nextInt();
int[] arr=new int[arrsize];
System.out.println("enter array elements");
for(int i=0;i<arrsize;i++){
arr[i]=sc.nextInt();
}
int oddsum=1; int evensum=1;
for(int i=0;i<arrsize;i++){
if(i%2!=0){
oddsum*=arr[i];
}
else{
evensum*=arr[i];
}
}
System.out.println("sum of product of odd indexed elements & even indexed elements is:"+(oddsum+evensum));
sc.close();
}
}