You’ve declared a function, but no return type has been given.
program Produce;
function Sum(A: array of Integer);
var I: Integer;
begin
Result := 0;
for I := 0 to High(A) do
Result := Result + A[I];
end;
begin
end.We haven’t instructed the compiler that Sum is supposed to be a function.
program Solve;
function Sum(A: array of Integer): Integer;
var I: Integer;
begin
Result := 0;
for I := 0 to High(A) do
Result := Result + A[I];
end;
begin
end.Just make sure the result type is specified.
Leave a Reply