How to resolve the algorithm Sum and product of an array step by step in the Delphi programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sum and product of an array step by step in the Delphi programming language

Table of Contents

Problem Statement

Compute the sum and product of an array of integers.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Sum and product of an array step by step in the Delphi programming language

Source code in the delphi programming language

program SumAndProductOfArray;

{$APPTYPE CONSOLE}

var
  i: integer;
  lIntArray: array [1 .. 5] of integer = (1, 2, 3, 4, 5);
  lSum: integer = 0;
  lProduct: integer = 1;
begin
  for i := 1 to length(lIntArray) do
  begin
    Inc(lSum, lIntArray[i]);
    lProduct := lProduct * lIntArray[i]
  end;

  Write('Sum: ');
  Writeln(lSum);
  Write('Product: ');
  Writeln(lProduct);
end.


  

You may also check:How to resolve the algorithm Farey sequence step by step in the Arturo programming language
You may also check:How to resolve the algorithm Matrix-exponentiation operator step by step in the C++ programming language
You may also check:How to resolve the algorithm Minimum multiple of m where digital sum equals m step by step in the COBOL programming language
You may also check:How to resolve the algorithm Matrix transposition step by step in the ActionScript programming language
You may also check:How to resolve the algorithm Word frequency step by step in the F# programming language