for i := 1 to 10 do begin write('Enter a number: '); readln(num);
if (num >= -5) and (num <= 18) then begin sum := sum + num; count := count + 1; end;
end;
if count > 0 then begin average := sum / count; writeln('Average of numbers in the interval [-5, 18]: ', average:0:2); end else writeln('No numbers in the interval [-5, 18] were entered.'); end.
program AverageCalculation;
var
num, sum, count: integer;
average: real;
begin
sum := 0;
count := 0;
for i := 1 to 10 do
if (num >= -5) and (num <= 18) thenbegin
write('Enter a number: ');
readln(num);
begin
sum := sum + num;
count := count + 1;
end;
end;
if count > 0 then
begin
average := sum / count;
writeln('Average of numbers in the interval [-5, 18]: ', average:0:2);
end
else
writeln('No numbers in the interval [-5, 18] were entered.');
end.