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:
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
- Latin for summa or a total.