WeixiangYan/CodeTransOcean huggingface dataset:
Task: XML_DOM serialization






PHP: <?php
$dom = new DOMDocument();//the constructor also takes the version and char-encoding as it's two respective parameters
$dom->formatOutput = true;//format the outputted xml
$root = $dom->createElement('root');
$element = $dom->createElement('element');
$element->appendChild($dom->createTextNode('Some text here'));
$root->appendChild($element);
$dom->appendChild($root);
$xmlstring = $dom->saveXML();






Ada: with Ada.Text_IO.Text_Streams;
with DOM.Core.Documents;
with DOM.Core.Nodes;

procedure Serialization is
   My_Implementation : DOM.Core.DOM_Implementation;
   My_Document       : DOM.Core.Document;
   My_Root_Node      : DOM.Core.Element;
   My_Element_Node   : DOM.Core.Element;
   My_Text_Node      : DOM.Core.Text;
begin
   My_Document := DOM.Core.Create_Document (My_Implementation);
   My_Root_Node := DOM.Core.Documents.Create_Element (My_Document, "root");
   My_Root_Node := DOM.Core.Nodes.Append_Child (My_Document, My_Root_Node);
   My_Element_Node := DOM.Core.Documents.Create_Element (My_Document, "element");
   My_Element_Node := DOM.Core.Nodes.Append_Child (My_Root_Node, My_Element_Node);
   My_Text_Node := DOM.Core.Documents.Create_Text_Node (My_Document, "Some text here");
   My_Text_Node := DOM.Core.Nodes.Append_Child (My_Element_Node, My_Text_Node);
   DOM.Core.Nodes.Write
     (Stream => Ada.Text_IO.Text_Streams.Stream
        (Ada.Text_IO.Standard_Output),
      N => My_Document,
      Pretty_Print => True);
end Serialization;
Task: XML_DOM serialization






PHP: <?php
$dom = new DOMDocument();//the constructor also takes the version and char-encoding as it's two respective parameters
$dom->formatOutput = true;//format the outputted xml
$root = $dom->createElement('root');
$element = $dom->createElement('element');
$element->appendChild($dom->createTextNode('Some text here'));
$root->appendChild($element);
$dom->appendChild($root);
$xmlstring = $dom->saveXML();
Task: Averages_Root mean square



C#: using System;

namespace rms
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            Console.WriteLine(rootMeanSquare(x));
        }

        private static double rootMeanSquare(int[] x)
        {            
            double sum = 0;
            for (int i = 0; i < x.Length; i++)
            {
                sum += (x[i]*x[i]);
            }
            return Math.Sqrt(sum / x.Length);
        }
    }
}









Ada: with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
	type float_arr is array(1..10) of Float;
	
	function rms(nums : float_arr) return Float is
		sum : Float := 0.0;
		begin
		for p in nums'Range loop
			sum := sum + nums(p)**2;
		end loop;
		return sqrt(sum/Float(nums'Length));
	end rms;

	list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
Task: Averages_Root mean square

C: #include <stdio.h>
#include <math.h>

double rms(double *v, int n)
{
  int i;
  double sum = 0.0;
  for(i = 0; i < n; i++)
    sum += v[i] * v[i];
  return sqrt(sum / n);
}

int main(void)
{
  double v[] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
  printf("%f\n", rms(v, sizeof(v)/sizeof(double)));
  return 0;
}











Ada: with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
	type float_arr is array(1..10) of Float;
	
	function rms(nums : float_arr) return Float is
		sum : Float := 0.0;
		begin
		for p in nums'Range loop
			sum := sum + nums(p)**2;
		end loop;
		return sqrt(sum/Float(nums'Length));
	end rms;

	list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
Task: Averages_Root mean square


C++: #include <iostream>
#include <vector>
#include <cmath>
#include <numeric>

int main( ) {
  std::vector<int> numbers ;
  for ( int i = 1 ; i < 11 ; i++ )
    numbers.push_back( i ) ;
  double meansquare = sqrt( ( std::inner_product( numbers.begin(), numbers.end(), numbers.begin(), 0 ) ) / static_cast<double>( numbers.size() ) );
  std::cout << "The quadratic mean of the numbers 1 .. " << numbers.size() << " is " << meansquare << " !\n" ;
  return 0 ;
}










Ada: with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
	type float_arr is array(1..10) of Float;
	
	function rms(nums : float_arr) return Float is
		sum : Float := 0.0;
		begin
		for p in nums'Range loop
			sum := sum + nums(p)**2;
		end loop;
		return sqrt(sum/Float(nums'Length));
	end rms;

	list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
Task: Averages_Root mean square




Go: package main

import (
    "fmt"
    "math"
)

func main() {
    const n = 10
    sum := 0.
    for x := 1.; x <= n; x++ {
        sum += x * x
    }
    fmt.Println(math.Sqrt(sum / n))
}








Ada: with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
	type float_arr is array(1..10) of Float;
	
	function rms(nums : float_arr) return Float is
		sum : Float := 0.0;
		begin
		for p in nums'Range loop
			sum := sum + nums(p)**2;
		end loop;
		return sqrt(sum/Float(nums'Length));
	end rms;

	list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
Task: Averages_Root mean square





Java: public class RootMeanSquare {

    public static double rootMeanSquare(double... nums) {
        double sum = 0.0;
        for (double num : nums)
            sum += num * num;
        return Math.sqrt(sum / nums.length);
    }

    public static void main(String[] args) {
        double[] nums = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
        System.out.println("The RMS of the numbers from 1 to 10 is " + rootMeanSquare(nums));
    }
}







Ada: with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
	type float_arr is array(1..10) of Float;
	
	function rms(nums : float_arr) return Float is
		sum : Float := 0.0;
		begin
		for p in nums'Range loop
			sum := sum + nums(p)**2;
		end loop;
		return sqrt(sum/Float(nums'Length));
	end rms;

	list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
Task: Averages_Root mean square







Python: sqrt(mean(x²))





Ada: with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
	type float_arr is array(1..10) of Float;
	
	function rms(nums : float_arr) return Float is
		sum : Float := 0.0;
		begin
		for p in nums'Range loop
			sum := sum + nums(p)**2;
		end loop;
		return sqrt(sum/Float(nums'Length));
	end rms;

	list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
Task: Averages_Root mean square








VB: Private Function root_mean_square(s() As Variant) As Double
    For i = 1 To UBound(s)
        s(i) = s(i) ^ 2
    Next i
    root_mean_square = Sqr(WorksheetFunction.sum(s) / UBound(s))
End Function
Public Sub pythagorean_means()
    Dim s() As Variant
    s = [{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]
    Debug.Print root_mean_square(s)
End Sub




Ada: with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
	type float_arr is array(1..10) of Float;
	
	function rms(nums : float_arr) return Float is
		sum : Float := 0.0;
		begin
		for p in nums'Range loop
			sum := sum + nums(p)**2;
		end loop;
		return sqrt(sum/Float(nums'Length));
	end rms;

	list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
Task: Averages_Root mean square

C: #include <stdio.h>
#include <math.h>

double rms(double *v, int n)
{
  int i;
  double sum = 0.0;
  for(i = 0; i < n; i++)
    sum += v[i] * v[i];
  return sqrt(sum / n);
}

int main(void)
{
  double v[] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
  printf("%f\n", rms(v, sizeof(v)/sizeof(double)));
  return 0;
}
Task: Averages_Root mean square



C#: using System;

namespace rms
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            Console.WriteLine(rootMeanSquare(x));
        }

        private static double rootMeanSquare(int[] x)
        {            
            double sum = 0;
            for (int i = 0; i < x.Length; i++)
            {
                sum += (x[i]*x[i]);
            }
            return Math.Sqrt(sum / x.Length);
        }
    }
}
Task: Averages_Root mean square


C++: #include <iostream>
#include <vector>
#include <cmath>
#include <numeric>

int main( ) {
  std::vector<int> numbers ;
  for ( int i = 1 ; i < 11 ; i++ )
    numbers.push_back( i ) ;
  double meansquare = sqrt( ( std::inner_product( numbers.begin(), numbers.end(), numbers.begin(), 0 ) ) / static_cast<double>( numbers.size() ) );
  std::cout << "The quadratic mean of the numbers 1 .. " << numbers.size() << " is " << meansquare << " !\n" ;
  return 0 ;
}
Task: Averages_Root mean square





Java: public class RootMeanSquare {

    public static double rootMeanSquare(double... nums) {
        double sum = 0.0;
        for (double num : nums)
            sum += num * num;
        return Math.sqrt(sum / nums.length);
    }

    public static void main(String[] args) {
        double[] nums = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
        System.out.println("The RMS of the numbers from 1 to 10 is " + rootMeanSquare(nums));
    }
}
Task: Averages_Root mean square







Python: sqrt(mean(x²))
Task: Averages_Root mean square








VB: Private Function root_mean_square(s() As Variant) As Double
    For i = 1 To UBound(s)
        s(i) = s(i) ^ 2
    Next i
    root_mean_square = Sqr(WorksheetFunction.sum(s) / UBound(s))
End Function
Public Sub pythagorean_means()
    Dim s() As Variant
    s = [{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]
    Debug.Print root_mean_square(s)
End Sub
Task: Averages_Root mean square




Go: package main

import (
    "fmt"
    "math"
)

func main() {
    const n = 10
    sum := 0.
    for x := 1.; x <= n; x++ {
        sum += x * x
    }
    fmt.Println(math.Sqrt(sum / n))
}
Task: Averages_Root mean square



C#: using System;

namespace rms
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            Console.WriteLine(rootMeanSquare(x));
        }

        private static double rootMeanSquare(int[] x)
        {            
            double sum = 0;
            for (int i = 0; i < x.Length; i++)
            {
                sum += (x[i]*x[i]);
            }
            return Math.Sqrt(sum / x.Length);
        }
    }
}








Fortran: print *,sqrt( sum(x**2)/size(x) )
Task: Averages_Root mean square


C++: #include <iostream>
#include <vector>
#include <cmath>
#include <numeric>

int main( ) {
  std::vector<int> numbers ;
  for ( int i = 1 ; i < 11 ; i++ )
    numbers.push_back( i ) ;
  double meansquare = sqrt( ( std::inner_product( numbers.begin(), numbers.end(), numbers.begin(), 0 ) ) / static_cast<double>( numbers.size() ) );
  std::cout << "The quadratic mean of the numbers 1 .. " << numbers.size() << " is " << meansquare << " !\n" ;
  return 0 ;
}









Fortran: print *,sqrt( sum(x**2)/size(x) )
Task: Averages_Root mean square

C: #include <stdio.h>
#include <math.h>

double rms(double *v, int n)
{
  int i;
  double sum = 0.0;
  for(i = 0; i < n; i++)
    sum += v[i] * v[i];
  return sqrt(sum / n);
}

int main(void)
{
  double v[] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
  printf("%f\n", rms(v, sizeof(v)/sizeof(double)));
  return 0;
}










Fortran: print *,sqrt( sum(x**2)/size(x) )
Task: Averages_Root mean square




Go: package main

import (
    "fmt"
    "math"
)

func main() {
    const n = 10
    sum := 0.
    for x := 1.; x <= n; x++ {
        sum += x * x
    }
    fmt.Println(math.Sqrt(sum / n))
}







Fortran: print *,sqrt( sum(x**2)/size(x) )
Task: Averages_Root mean square





Java: public class RootMeanSquare {

    public static double rootMeanSquare(double... nums) {
        double sum = 0.0;
        for (double num : nums)
            sum += num * num;
        return Math.sqrt(sum / nums.length);
    }

    public static void main(String[] args) {
        double[] nums = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
        System.out.println("The RMS of the numbers from 1 to 10 is " + rootMeanSquare(nums));
    }
}






Fortran: print *,sqrt( sum(x**2)/size(x) )
Task: Averages_Root mean square








VB: Private Function root_mean_square(s() As Variant) As Double
    For i = 1 To UBound(s)
        s(i) = s(i) ^ 2
    Next i
    root_mean_square = Sqr(WorksheetFunction.sum(s) / UBound(s))
End Function
Public Sub pythagorean_means()
    Dim s() As Variant
    s = [{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]
    Debug.Print root_mean_square(s)
End Sub



Fortran: print *,sqrt( sum(x**2)/size(x) )
Task: Averages_Root mean square






PHP: <?php


function rms(array $numbers)
{
    $sum = 0;

    foreach ($numbers as $number) {
        $sum += $number**2;
    }

    return sqrt($sum / count($numbers));
}

echo rms(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));





Fortran: print *,sqrt( sum(x**2)/size(x) )
Task: Averages_Root mean square

C: #include <stdio.h>
#include <math.h>

double rms(double *v, int n)
{
  int i;
  double sum = 0.0;
  for(i = 0; i < n; i++)
    sum += v[i] * v[i];
  return sqrt(sum / n);
}

int main(void)
{
  double v[] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
  printf("%f\n", rms(v, sizeof(v)/sizeof(double)));
  return 0;
}









COBOL: 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.
Task: Averages_Root mean square



C#: using System;

namespace rms
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            Console.WriteLine(rootMeanSquare(x));
        }

        private static double rootMeanSquare(int[] x)
        {            
            double sum = 0;
            for (int i = 0; i < x.Length; i++)
            {
                sum += (x[i]*x[i]);
            }
            return Math.Sqrt(sum / x.Length);
        }
    }
}







COBOL: 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.
Task: Averages_Root mean square


C++: #include <iostream>
#include <vector>
#include <cmath>
#include <numeric>

int main( ) {
  std::vector<int> numbers ;
  for ( int i = 1 ; i < 11 ; i++ )
    numbers.push_back( i ) ;
  double meansquare = sqrt( ( std::inner_product( numbers.begin(), numbers.end(), numbers.begin(), 0 ) ) / static_cast<double>( numbers.size() ) );
  std::cout << "The quadratic mean of the numbers 1 .. " << numbers.size() << " is " << meansquare << " !\n" ;
  return 0 ;
}








COBOL: 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.
Task: Averages_Root mean square





Java: public class RootMeanSquare {

    public static double rootMeanSquare(double... nums) {
        double sum = 0.0;
        for (double num : nums)
            sum += num * num;
        return Math.sqrt(sum / nums.length);
    }

    public static void main(String[] args) {
        double[] nums = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
        System.out.println("The RMS of the numbers from 1 to 10 is " + rootMeanSquare(nums));
    }
}





COBOL: 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.
Task: Averages_Root mean square







Python: sqrt(mean(x²))



COBOL: 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.
Task: Averages_Root mean square








VB: Private Function root_mean_square(s() As Variant) As Double
    For i = 1 To UBound(s)
        s(i) = s(i) ^ 2
    Next i
    root_mean_square = Sqr(WorksheetFunction.sum(s) / UBound(s))
End Function
Public Sub pythagorean_means()
    Dim s() As Variant
    s = [{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]
    Debug.Print root_mean_square(s)
End Sub


COBOL: 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.
Task: Averages_Root mean square




Go: package main

import (
    "fmt"
    "math"
)

func main() {
    const n = 10
    sum := 0.
    for x := 1.; x <= n; x++ {
        sum += x * x
    }
    fmt.Println(math.Sqrt(sum / n))
}






COBOL: 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.
Task: Averages_Root mean square






PHP: <?php


function rms(array $numbers)
{
    $sum = 0;

    foreach ($numbers as $number) {
        $sum += $number**2;
    }

    return sqrt($sum / count($numbers));
}

echo rms(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
Task: Averages_Root mean square






PHP: <?php


function rms(array $numbers)
{
    $sum = 0;

    foreach ($numbers as $number) {
        $sum += $number**2;
    }

    return sqrt($sum / count($numbers));
}

echo rms(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));






Ada: with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
	type float_arr is array(1..10) of Float;
	
	function rms(nums : float_arr) return Float is
		sum : Float := 0.0;
		begin
		for p in nums'Range loop
			sum := sum + nums(p)**2;
		end loop;
		return sqrt(sum/Float(nums'Length));
	end rms;

	list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
Task: Averages_Root mean square






PHP: <?php


function rms(array $numbers)
{
    $sum = 0;

    foreach ($numbers as $number) {
        $sum += $number**2;
    }

    return sqrt($sum / count($numbers));
}

echo rms(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));




COBOL: 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.
Task: Scope modifiers



C#: public 
protected 
internal 
protected internal 
private 

private protected 




















Ada: package P is
   ... 
private
   ... 
end P;
Task: Scope modifiers

C: int a;          
static int p;   

extern float v; 


int code(int arg)
{
  int myp;        
                  
                  
  static int myc; 
                  
                  
                  
                  
}


static void code2(void)
{
  v = v * 1.02;    
  
}











Ada: package P is
   ... 
private
   ... 
end P;
Task: Scope modifiers





Java: public 

protected 


private 

static 

















public void function(int x){
   
   int y;
   
   {
      int z;
      
   }
   
}







Ada: package P is
   ... 
private
   ... 
end P;