forked from joharbatta/DataStructure-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAvgArray.java
More file actions
29 lines (27 loc) · 580 Bytes
/
AvgArray.java
File metadata and controls
29 lines (27 loc) · 580 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.*;
public class AvgArray
{
public static void main(String args[])
{
int sum=0;
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=s.nextInt();
}
for(int i=0;i<n;i++)
{
sum+=arr[i];
}
for(int i=n-1;i>=0;i--)
{
System.out.print(arr[i]+" ");
}
System.out.println();
double avg;
avg=(double)sum/n;
System.out.println(avg);
}
}