-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray-05
More file actions
53 lines (35 loc) · 883 Bytes
/
Array-05
File metadata and controls
53 lines (35 loc) · 883 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*In this program, we will learn how to find the mean of an array. Here, we are reading N elements and finding their mean element.
Input Format
The first input consists of an array size.
The Second input consists of elements of an array.
Constraints
No Constraints
Output Format
Find the Mean Value of an array.
Sample Input 0
5
9 4 1 2 3
Sample Output 0
Mean:3.80
Sample Input 1
4
9 7 2 5
Sample Output 1
Mean:5.75*/
##Output:
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
procedure Solution is
N : Integer;
Sum : Integer := 0;
X : Integer;
Mean : Float;
begin
Ada.Integer_Text_IO.Get(N);
for I in 1 .. N loop
Ada.Integer_Text_IO.Get(X);
Sum := Sum + X;
end loop;
Mean := Float(Sum) / Float(N);
Ada.Text_IO.Put("Mean:");
Ada.Float_Text_IO.Put(Item => Mean, Fore => 1, Aft => 2, Exp => 0);
end Solution;