How to resolve the algorithm Averages/Arithmetic mean step by step in the Rapira programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Averages/Arithmetic mean step by step in the Rapira programming language

Table of Contents

Problem Statement

Write a program to find the mean (arithmetic average) of a numeric vector. In case of a zero-length input, since the mean of an empty set of numbers is ill-defined, the program may choose to behave in any way it deems appropriate, though if the programming language has an established convention for conveying math errors or undefined values, it's preferable to follow it.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Averages/Arithmetic mean step by step in the Rapira programming language

Source code in the rapira programming language

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

  

You may also check:How to resolve the algorithm RSA code step by step in the Ruby programming language
You may also check:How to resolve the algorithm CRC-32 step by step in the Visual Basic programming language
You may also check:How to resolve the algorithm Factors of an integer step by step in the ALGOL-M programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the Fortran programming language
You may also check:How to resolve the algorithm Catalan numbers step by step in the Phix programming language