RAD Studio Athens

E2023

Go Up to Error and Warning Messages (Delphi)

You have declared a function, but have not specified a return type.


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.

Here Sum is meant to be function, we have not told the compiler about it.


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 you specify the result type.