By Kardi Teknomo, PhD .

< Previous | Next | Contents >

How do we code Sum in a program?

Here is how to make sum Function in programming code (VB style)

Sum Function

Function Sum (array() as Double, firstIndex as Integer, lastIndex as Integer) as Double

Return summation of numbers in the array specified by firstIndex to lastIndex

Dim k as Integer declare the counter

For k = firstIndex to lastIndex

Sum=Sum + array(k)

Next k

End Function

< Previous | Next | Contents >

See Also: Kardi Teknomo's Tutorial

Rate this tutorial

This tutorial is copyrighted .

Preferable reference for this tutorial is

Teknomo, Kardi (2015) Summation Tutorial.