Math Statistics with Arrays

Kenneth Leroy Busbee and Dave Braunschweig


Statistics is a branch of mathematics dealing with the collection, organization, analysis, interpretation, and presentation of data. Common statistical methods include mean (or average) and standard deviation.[1]


Arrays are an important complex data type used in almost all programming. We continue to concentrate on simple one dimension arrays also called a list. Most programmers develop a series of user-defined specific task functions that can be used with an array for normal processing. These functions are usually passed the array along with the number of elements within the array. Some functions also pass another piece of data needed for that particular functions task.

This module covers the totaling of the members of an integer array member. The Latin name for totaling is summa, sometimes shortened to the word sum. In the example below, the sum function totals the array passed to it. Other mathematical functions often associated with statistics such as: average, count, minimum, maximum, standard deviation, etc. are often developed for processing arrays.


Function Main
    Declare Integer Array ages[5]
    Declare Integer total
    Assign ages = [49, 48, 26, 19, 16]

    Assign total = sum(ages)

    Output "Total age is: " & total

Function sum (Integer Array array)
    Declare Integer total
    Declare Integer index
    Assign total = 0
    For index = 0 to Size(array) - 1
        Assign total = total + array[index]
Return Integer total


Total age is: 158

Key Terms

Latin for summa or a total.



Icon for the Creative Commons Attribution-ShareAlike 4.0 International License

Programming Fundamentals Copyright © 2018 by Kenneth Leroy Busbee and Dave Braunschweig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book