In your Delphi program, You’ve declared a procedure but haven’t specified a result type for it. Either you meant to declare a function or the result type should be removed.
program Produce;
procedure DotProduct(const A,B: array of Double): Double;
var
I: Integer;
begin
Result := 0.0;
for I := 0 to High(A) do
Result := Result + A[I]*B[I];
end;
const
C: array [1..3] of Double = (1,2,3);
begin
Writeln( DotProduct(C,C) );
end.DotProduct was actually intended to be a function, but we used the wrong term.
program Solve;
function DotProduct(const A,B: array of Double): Double;
var
I: Integer;
begin
Result := 0.0;
for I := 0 to High(A) do
Result := Result + A[I]*B[I];
end;
const
C: array [1..3] of Double = (1,2,3);
begin
Writeln( DotProduct(C,C) );
end.When declaring a function, be sure to specify a result type; when declaring a procedure, make sure to indicate no result type.
Leave a Reply