-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay18_prob2.java
More file actions
52 lines (40 loc) · 995 Bytes
/
Day18_prob2.java
File metadata and controls
52 lines (40 loc) · 995 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
Narayana friends ask him to write a java code to find the sum of all even number which is store in one dimensional array.
if the array does not have any even number then print 0 else print the sum.
Input Format
Accept the size of array n
Enter the n number of element.
Constraints
5 < n > 50
Output Format
print the sum
Sample Input 0
5
10
15
20
35
45
Sample Output 0
30
*/
// kirtan jain
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner in = new Scanner(System.in);
int size = in.nextInt();
int sum = 0;
int[] arr = new int[size];
for(int i = 0 ; i <size; i++){
arr[i] = in.nextInt();
//in.nextLine();
if(arr[i] % 2 == 0){
sum += arr[i];
}
}
System.out.print(sum);
}
}