Skip to content

Commit ad08916

Browse files
Merge pull request #9 from saravanan81java/IssueFix6
Issue Fix
2 parents 20d2074 + c9504e3 commit ad08916

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/com/.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.array.rotations;
2+
3+
public class ArrayAverage {
4+
5+
public static void main(String[] args) {
6+
int n = 10;
7+
int[] arr = new int[n];
8+
9+
// Input array elements
10+
System.out.println("Enter the elements of the array: ");
11+
for (int i = 0; i < n; i++) {
12+
arr[i] = 1+i;
13+
}
14+
15+
// Calculate sum of elements
16+
int sum = 0;
17+
for (int i = 0; i < n; i++) {
18+
sum += arr[i];
19+
}
20+
21+
// Calculate average
22+
double average = (double) sum / n;
23+
24+
// Output the average
25+
System.out.println("The average is: " + average);
26+
27+
}
28+
29+
}

0 commit comments

Comments
 (0)