Task

Write a program to find the sum of squares of a numeric vector.

The program should work on a zero-length vector (with an answer of   0).



Related task

   Mean


program SumOfSq;
 
{$APPTYPE CONSOLE}
 
uses Math;
 
type
  TDblArray = array of Double;
 
var
  A: TDblArray;
 
begin
  Writeln(SumOfSquares([]):6:2);            //  0.00
  Writeln(SumOfSquares([1, 2, 3, 4]):6:2);  // 30.00
  A:= nil;
  Writeln(SumOfSquares(A):6:2);             //  0.00
  A:= TDblArray.Create(1, 2, 3, 4);
  Writeln(SumOfSquares(A):6:2);             // 30.00
  Readln;
end.