+ 1
How to write a program dat reads a set of integers then displays the sum of all even nos. & sum of all odd nos.
Example Output: Enter Series of Numbers 2 6 89 45 22 3 90 The sum of Even Numbers is: 120 The Sum of Odd Numbers is: 137
3 Respuestas
+ 10
John Kevin Laurencio
public class Program
{
public static void main(String[] args) {
int []arr={25,35,44,99,88,2};
int sum_odd=0,sum_even=0;
for(int i=0;i<arr.length;i++)
if(arr[i]%2!=0)sum_odd+=arr[i];
else sum_even+=arr[i];
System.out.println(sum_odd);
System.out.println(sum_even);
}
}
+ 2
You have to post your try (eg. your code) because this seem an assignement and hardly you will find someone that make it for you
0
im a noob in programming. pls help