Write a program in Java to find the largest even and smallest odd number from a list
of numbers entered by the user. The program terminates as soon as zero is entered
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]);
}
}
}}
Explanation:
write and see the output
Similar questions
CBSE BOARD XII,
3 months ago
English,
3 months ago
Science,
3 months ago
Science,
6 months ago
Math,
10 months ago