Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified src/com/.DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions src/com/array/rotations/ArrayAverage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.array.rotations;

public class ArrayAverage {

public static void main(String[] args) {
int n = 10;
int[] arr = new int[n];

// Input array elements
System.out.println("Enter the elements of the array: ");
for (int i = 0; i < n; i++) {
arr[i] = 1+i;
}

// Calculate sum of elements
int sum = 0;
for (int i = 0; i < n; i++) {
sum += arr[i];
}

// Calculate average
double average = (double) sum / n;

// Output the average
System.out.println("The average is: " + average);

}

}