How to resolve the algorithm Sum of squares step by step in the VBScript programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sum of squares step by step in the VBScript programming language
Table of Contents
Problem Statement
Write a program to find the sum of squares of a numeric vector. The program should work on a zero-length vector (with an answer of 0).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sum of squares step by step in the VBScript programming language
Source code in the vbscript programming language
Function sum_of_squares(arr)
If UBound(arr) = -1 Then
sum_of_squares = 0
End If
For i = 0 To UBound(arr)
sum_of_squares = sum_of_squares + (arr(i)^2)
Next
End Function
WScript.StdOut.WriteLine sum_of_squares(Array(1,2,3,4,5))
WScript.StdOut.WriteLine sum_of_squares(Array())
You may also check:How to resolve the algorithm Scope modifiers step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Gecho programming language
You may also check:How to resolve the algorithm File size distribution step by step in the zkl programming language
You may also check:How to resolve the algorithm Factors of an integer step by step in the APL programming language
You may also check:How to resolve the algorithm Non-decimal radices/Convert step by step in the C programming language