How to resolve the algorithm Averages/Root mean square step by step in the Sather programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Averages/Root mean square step by step in the Sather 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 Sather programming language
Source code in the sather programming language
class MAIN is
-- irrms stands for Integer Ranged RMS
irrms(i, f:INT):FLT
pre i <= f
is
sum ::= 0;
loop
sum := sum + i.upto!(f).pow(2);
end;
return (sum.flt / (f-i+1).flt).sqrt;
end;
main is
#OUT + irrms(1, 10) + "\n";
end;
end;
You may also check:How to resolve the algorithm Arrays step by step in the Pascal programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the LabVIEW programming language
You may also check:How to resolve the algorithm Sorting algorithms/Bogosort step by step in the J programming language
You may also check:How to resolve the algorithm Loops/Wrong ranges step by step in the Go programming language
You may also check:How to resolve the algorithm Fast Fourier transform step by step in the Ursala programming language