<< Chapter < Page Chapter >> Page >
An introduction to functions performing statistical calculations on an array within the C++ programming language.

Overview

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 of 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 . The array function is often called "sum" and it does some parameter passing. It passes into the function the common two items of the array: its name along with the number of elements; but it also returns a value representing sum or total of the values within the array. You need to study this module in conjunction with the demo file provided.

Other mathematical functions often associated with statistics such as: average, count, minimum, maximum, standard deviation, etc. are often developed for processing arrays.

Demonstration program in c++

Creating a folder or sub-folder for source code files

Depending on your compiler/IDE, you should decide where to download and store source code files for processing. Prudence dictates that you create these folders as needed prior to downloading source code files. A suggested sub-folder for the Bloodshed Dev-C++ 5 compiler/IDE might be named:

  • Demo_Programs

If you have not done so, please create the folder(s) and/or sub-folder(s) as appropriate.

Download the demo program

Download and store the following file(s) to your storage device in the appropriate folder(s). Following the methods of your compiler/IDE, compile and run the program(s). Study the source code file(s) in conjunction with other learning materials. You may need to right click on the link and select "Save Target As" in order to download the file.

Download from Connexions: Demo_Sum_ Array_Function.cpp

Download from Connexions: Demo_Farm_Acres_Input.txt

Definitions

sum
Latin for summa or a total.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Programming fundamentals - a modular structured approach using c++. OpenStax CNX. Jan 10, 2013 Download for free at http://cnx.org/content/col10621/1.22
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Programming fundamentals - a modular structured approach using c++' conversation and receive update notifications?

Ask