How to resolve the algorithm Averages/Root mean square step by step in the COBOL programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Averages/Root mean square step by step in the COBOL 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 COBOL programming language

Source code in the cobol programming language

IDENTIFICATION DIVISION.
PROGRAM-ID. QUADRATIC-MEAN-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  QUADRATIC-MEAN-VARS.
    05 N               PIC 99        VALUE 0.
    05 N-SQUARED       PIC 999.
    05 RUNNING-TOTAL   PIC 999       VALUE 0.
    05 MEAN-OF-SQUARES PIC 99V9(16).
    05 QUADRATIC-MEAN  PIC 9V9(15).
PROCEDURE DIVISION.
CONTROL-PARAGRAPH.
    PERFORM MULTIPLICATION-PARAGRAPH 10 TIMES.
    DIVIDE  RUNNING-TOTAL BY 10 GIVING MEAN-OF-SQUARES.
    COMPUTE QUADRATIC-MEAN = FUNCTION SQRT(MEAN-OF-SQUARES).
    DISPLAY QUADRATIC-MEAN UPON CONSOLE.
    STOP RUN.
MULTIPLICATION-PARAGRAPH.
    ADD      1         TO N.
    MULTIPLY N         BY N GIVING N-SQUARED.
    ADD      N-SQUARED TO RUNNING-TOTAL.


  

You may also check:How to resolve the algorithm ABC problem step by step in the SNOBOL4 programming language
You may also check:How to resolve the algorithm Fivenum step by step in the 11l programming language
You may also check:How to resolve the algorithm JortSort step by step in the Raku programming language
You may also check:How to resolve the algorithm Babbage problem step by step in the Raku programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the Raven programming language