Question: 3. Functions with 1-D arrays as parameters Consider a function, named calcDOT that calculates the DOT product of two vectors (each represented as a one


3. Functions with 1-D arrays as parameters Consider a function, named calcDOT that calculates the DOT product of two vectors (each represented as a one dimensional array). Recall that the DOT product is the scalar (single value) sum of products of two vectors. That is, for A and B two n-element vectors: 7-1 Dot Product = A - B= a, bt W K=0 The function takes three (3) parameters: n, an int that indicates the length of the vectors, A a one dimensional array of type double B a one dimensional array of type double (assume A and B are of equal length) For example, ilf A is 2 3 41 and B is 3 45 2, then the dot product is 2*3+3*4+4*5+1*2= 40 a) Write the function calcDOT: a) Write the function calcDOT: WA b) In main(), statically initialize two 1-D arrays (vectors of type double) named X and Y of length 3 using values of your choice. c) Call (invoke) the function calcDOT with appropriate parameters and store the result returned from calcDOT in a variable declared as Result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
