Write a program in Java to enter ten numbers and display the even numbers and finally print the sum of odd numbers.
Answers
Answered by
2
Answer:
public class OddEvenInArrayExample{
public static void main(String args[]){
int a[]={1,2,5,6,3,2};
System.out.println("Odd Numbers:");
for(int i=0;i<a.length;i++){
if(a[i]%2!=0){
System.out.println(a[i]);
}
}
System.out.println("Even Numbers:");
for(int i=0;i<a.length;i++){
if(a[i]%2==0){
System.out.println(a[i]);
}
}
}}
Odd Numbers: 1 5 3 Even Numbers: 2 6 2
MARK AS BRAINLIEST
Similar questions