How to resolve the algorithm Averages/Arithmetic mean step by step in the VBScript programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Averages/Arithmetic mean step by step in the VBScript programming language
Table of Contents
Problem Statement
Write a program to find the mean (arithmetic average) of a numeric vector. In case of a zero-length input, since the mean of an empty set of numbers is ill-defined, the program may choose to behave in any way it deems appropriate, though if the programming language has an established convention for conveying math errors or undefined values, it's preferable to follow it.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Averages/Arithmetic mean step by step in the VBScript programming language
Source code in the vbscript programming language
Function mean(arr)
size = UBound(arr) + 1
mean = 0
For i = 0 To UBound(arr)
mean = mean + arr(i)
Next
mean = mean/size
End Function
'Example
WScript.Echo mean(Array(3,1,4,1,5,9))
You may also check:How to resolve the algorithm Trigonometric functions step by step in the Perl programming language
You may also check:How to resolve the algorithm Character codes step by step in the Eiffel programming language
You may also check:How to resolve the algorithm Animate a pendulum step by step in the Fortran programming language
You may also check:How to resolve the algorithm Combinations with repetitions step by step in the Swift programming language
You may also check:How to resolve the algorithm Cholesky decomposition step by step in the Tcl programming language