How to resolve the algorithm Averages/Root mean square step by step in the Oberon-2 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Averages/Root mean square step by step in the Oberon-2 programming language

Table of Contents

Problem Statement

Compute the   Root mean square   of the numbers 1..10.

The   root mean square   is also known by its initials RMS (or rms), and as the quadratic mean. The RMS is calculated as the mean of the squares of the numbers, square-rooted:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Averages/Root mean square step by step in the Oberon-2 programming language

Source code in the oberon-2 programming language

MODULE QM;
IMPORT ML := MathL, Out;
VAR
	nums: ARRAY 10 OF LONGREAL;
	i: INTEGER;
	
PROCEDURE Rms(a: ARRAY OF LONGREAL): LONGREAL;
VAR
	i: INTEGER;
	s: LONGREAL;
BEGIN
	s := 0.0;
	FOR i := 0 TO LEN(a) - 1 DO
		s := s + (a[i] * a[i])
	END;
	RETURN ML.Sqrt(s / LEN(a))
END Rms;
	
BEGIN
	FOR i := 0 TO LEN(nums) - 1 DO
		nums[i] := i + 1
	END;
	Out.String("Quadratic Mean: ");Out.LongReal(Rms(nums));Out.Ln
END QM.

  

You may also check:How to resolve the algorithm Convert decimal number to rational step by step in the МК-61/52 programming language
You may also check:How to resolve the algorithm Bitmap/Write a PPM file step by step in the REXX programming language
You may also check:How to resolve the algorithm Detect division by zero step by step in the Wren programming language
You may also check:How to resolve the algorithm Pi step by step in the J programming language
You may also check:How to resolve the algorithm Sierpinski pentagon step by step in the Mathematica/Wolfram Language programming language