Averages/Arithmetic mean: Difference between revisions
Content added Content deleted
Line 1,153: | Line 1,153: | ||
Alternative version using the Math unit: |
Alternative version using the Math unit: |
||
<lang pascal>Program |
<lang pascal>Program DoMean; |
||
uses math; |
uses math; |
||
const |
const |
||
Line 1,159: | Line 1,159: | ||
var |
var |
||
i: integer; |
i: integer; |
||
mean: double; |
|||
begin |
begin |
||
writeln('Calculating the arithmetic mean of a series of numbers:'); |
writeln('Calculating the arithmetic mean of a series of numbers:'); |
||
Line 1,165: | Line 1,166: | ||
write (vector[i]:3:1, ' '); |
write (vector[i]:3:1, ' '); |
||
writeln (']'); |
writeln (']'); |
||
mean := 0; |
|||
⚫ | |||
if length(vector) > 0 then |
|||
mean := sum(vector)/length(vector); |
|||
⚫ | |||
end.</lang> |
end.</lang> |
||