See More

//Program to find sum of all the array elements, sum of positive, sum of negative, sum of even, sum of odd numbers from the array. import java.util.Scanner; public class SumOFArrayElements { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println(" Enter the size of the array: "); int n=sc.nextInt(); int[] arr=new int[n]; System.out.println(" Enter the elements: "); for(int i=0; i0) { sum=sum+arr[i]; } } return sum; } public static int sumOfNegative(int[] arr) { int sum=0; for(int i=0; i