Написать программу на паскале, которая будет считать сумму и среднее арифметическое 10 чисел, введенных массивом, используя процедуры или функции (!!!)
type NumberArray = array[1..NumOfElements] of Integer;
var numbers: NumberArray; sum, average: Real; i: Integer;
procedure CalculateSumAndAverage(var numbers: NumberArray; var sum, average: Real); var i: Integer; begin sum := 0; for i := 1 to NumOfElements do sum := sum + numbers[i];
average := sum / NumOfElements; end;
begin writeln('Enter 10 numbers:'); for i := 1 to NumOfElements do readln(numbers[i]);
CalculateSumAndAverage(numbers, sum, average);
writeln('Sum of the numbers: ', sum:0:2); writeln('Average of the numbers: ', average:0:2); end.
program SumAndAverage;
const
NumOfElements = 10;
type
NumberArray = array[1..NumOfElements] of Integer;
var
numbers: NumberArray;
sum, average: Real;
i: Integer;
procedure CalculateSumAndAverage(var numbers: NumberArray; var sum, average: Real);
var
i: Integer;
begin
sum := 0;
for i := 1 to NumOfElements do
sum := sum + numbers[i];
average := sum / NumOfElements;
end;
begin
writeln('Enter 10 numbers:');
for i := 1 to NumOfElements do
readln(numbers[i]);
CalculateSumAndAverage(numbers, sum, average);
writeln('Sum of the numbers: ', sum:0:2);
writeln('Average of the numbers: ', average:0:2);
end.