Generation

generate functionWed, 15 Feb 2023

compute sum of negative elements of one-dimensional array which contain float elements

public static double computeSumOfNegativeElements(float[] array) { double result = 0; for (int i = 0; i < array.length; i++) { if (array[i] < 0) { result = result + array[i]; } } return result; }

Questions about programming?Chat with your personal AI assistant