3. Write a program to find average of array values

public class Main {
    public static void main(String[] args) {
        double[] numbers={14,12,9,15,17,21,23,5,8,25};
        double sum=0;
        for(int i=0;i<numbers.length;i++){
            sum+=numbers[i];Average is: 14.9
        }
        double average=sum/numbers.length;
        System.out.println("Average is: "+average);

    }
}
Output:
Average is: 14.9
about author

admin

salmansrabon@gmail.com

If you like my post or If you have any queries, do not hesitate to leave a comment.

One Comment on "3. Write a program to find average of array values"

Leave a Reply

Your email address will not be published. Required fields are marked *