How to resolve the algorithm Sum and product of an array step by step in the Rapira 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 Rapira 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 Rapira programming language

Source code in the rapira programming language

fun sumOfArr(arr)
  sum := 0
  for N from 1 to #arr do
    sum := sum + arr[N]
  od
  return sum
end

fun productOfArr(arr)
  product := arr[1]
  for N from 2 to #arr do
    product := product * arr[N]
  od
  return product
end

  

You may also check:How to resolve the algorithm Accumulator factory step by step in the Scheme programming language
You may also check:How to resolve the algorithm Percentage difference between images step by step in the Ruby programming language
You may also check:How to resolve the algorithm Hilbert curve step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Subtractive generator step by step in the PL/I programming language
You may also check:How to resolve the algorithm Huffman coding step by step in the C programming language