program AverageEvenNumbers; var n, num, sum, count: integer; avg: real; begin n := 8; sum := 0; count := 0; for num := 1 to n do begin if num mod 2 = 0 then begin sum := sum + num; count := count + 1; end; end; if count > 0 then avg := sum / count else avg := 0; writeln('Среднее арифметическое чётных чисел от 1 до ', n, ' равно ', avg:0:2); end.
var
n, num, sum, count: integer;
avg: real;
begin
n := 8;
sum := 0;
count := 0;
for num := 1 to n do
begin
if num mod 2 = 0 then
begin
sum := sum + num;
count := count + 1;
end;
end;
if count > 0 then
avg := sum / count
else
avg := 0;
writeln('Среднее арифметическое чётных чисел от 1 до ', n, ' равно ', avg:0:2);
end.