-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproductOfElement.java
More file actions
38 lines (25 loc) · 887 Bytes
/
productOfElement.java
File metadata and controls
38 lines (25 loc) · 887 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
27
28
29
30
31
32
33
34
35
36
37
38
import java.io.BufferedReader;
import java.io.InputStreamReader;
// Writer the program to print the product of the even element in the array
public class productOfElement {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the size of the array: ");
int size = Integer.parseInt(br.readLine());
int a[] = new int[size];
System.out.println("Enter the array element: ");
for(int i=0;i<size;i++)
{
a[i] = Integer.parseInt(br.readLine());
}
int mult = 1;
for(int i=0;i<a.length;i++)
{
if(a[i] % 2==0)
{
mult = mult * a[i];
}
}
System.out.println("The product of the even element is: "+mult);
}
}