Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question