M
M
Maks Kulikov2019-11-05 10:34:21
Pascal
Maks Kulikov, 2019-11-05 10:34:21

How to find the arithmetic mean of elements in a non-empty list?

I can not write a function in any way to find the arithmetic mean of the elements of a list in Pascal. Please advise how this can be implemented. I will be very grateful!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter Slobodyanyuk, 2019-11-05
@PeterLS

uses crt;
 
type
    massiv = array [1..1000] of integer;
 
var
    i,n,summa : integer;
    srednee : real;
    A : massiv;
begin
    clrscr;
    write('Введите кол-во элементов : ');readln(n);
 
    summa := 0 ;
    for i:=1 to n do
        begin
            write('Введите ',i, ' элемент : '); readln(A[i]);
            summa := summa + A[i];
        end;
    srednee := summa / n;
 
    writeln('Среднее арифметическое ', srednee:3:2); // округляем 
 
    readln;
end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question