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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!