program AverageEvenNumbers;
varN, i, sum, count: integer;average: real;
beginsum := 0;count := 0;
writeln('Enter a number N:');readln(N);
for i := 1 to N dobeginif (i mod 2 = 0) and (i > 0) thenbeginsum := sum + i;count := count + 1;end;end;
if count > 0 thenaverage := sum / countelseaverage := 0;
writeln('The average of positive even numbers up to ', N, ' is: ', average:0:2);
end.
program AverageEvenNumbers;
var
N, i, sum, count: integer;
average: real;
begin
sum := 0;
count := 0;
writeln('Enter a number N:');
readln(N);
for i := 1 to N do
begin
if (i mod 2 = 0) and (i > 0) then
begin
sum := sum + i;
count := count + 1;
end;
end;
if count > 0 then
average := sum / count
else
average := 0;
writeln('The average of positive even numbers up to ', N, ' is: ', average:0:2);
end.