Skip to content

Commit b4999db

Browse files
committed
Implement odd integer count prog
1 parent 4fc7399 commit b4999db

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import java.util.Scanner;
2+
import java.util.*;
3+
4+
public class oddIntegerCount {
5+
6+
static int findOdd(int []arr, int n){
7+
8+
int sum=0;
9+
for(int i=0; i<n; i++){
10+
if(arr[i]%2==1){
11+
sum+=arr[i];
12+
}
13+
}
14+
15+
return sum;
16+
}
17+
18+
public static void main(String[] args) {
19+
System.out.println("Enter the array lenth: ");
20+
Scanner sc=new Scanner(System.in);
21+
int n=sc.nextInt();
22+
23+
int arr[]=new int[n];
24+
System.out.println("Enter the array");
25+
for(int i=0; i<n; i++){
26+
arr[i]=sc.nextInt();
27+
}
28+
int ans=findOdd(arr,n);
29+
System.out.println("Answer: "+ans);
30+
31+
}
32+
33+
}

0 commit comments

Comments
 (0)