Running total

Running total is used to add values to an existing variable.

The technique can also be used to join strings to an existing string.

The important bit of code is of the format total = total + newValue.

Example code – totalling user inputs     show
Example code – totalling numbers stored in an array     show
Example code – joining strings together     show

Back to index

mph@ghscomputing.co.uk

Updated 07 January 2019