Question: Code in C++ please A. Dot Product (20 points) Let v and be two n-dimensional vectors. Their dot product is the sum of the products
A. Dot Product (20 points) Let v and be two n-dimensional vectors. Their dot product is the sum of the products of their respective components. For example, if n is 4, v is the vector (1,0,2,1) and w is the vector (-1,2, 1,4), then their dot product is 1x(-1) + 0 x 2 +2 x 1 + 1 x 4 = 5. Write a C++ program that does the following: 1. Has the user to input an integer n. 2. Dynamically allocates two n-dimensional vectors of doubles 3. Has the user input the components for the two vectors. 4. Computes and prints out the dot product 5. Deletes the two vectors. 6. All the steps above should be in a continuation loop, so the user can repeat the process as many times as he or she wishes. Here is an example of program input and out put: Enter number of components per vector: 2 En ter components for v: 2.1 1.0 En ter components for w: 2.0 1.2 Dot product: 5.4 Compute another dot product (y)? y Enter number of components per vector: 4 En ter components for v: 1 2 3 4 Enter components for w: 2 3 2-1 Dot product: 10 Compute another dot product (y)? n Here are a few comments/reminders: You must dynamically allocate the vectors. . Remember to delete the vectors at the end of each iteration of the continuation loop. You may assume that all the input is valid. For example, you do not need to check whether the value that the user inputs for n is a positive integer .Make sure your output follows the format in the example
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
