Question: C++ Dot Product using dynamic allocation Write a C++ program that does the following 1. Has the user to input an integer n 2. Dynamically
C++ Dot Product using dynamic allocation
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 steps above should be in a continuation loop, so the user can repeat the process as many times as they wish
Example input and output from the program
Enter number of components per vector: 2
Enter components for v: 2.1 1.0
Enter components for w: 2.0 1.2
Dot product: 5.4
Compute another dot product (y/n)? y
Enter number of components per vector: 4
Enter components for v: 1 2 3 4
Enter components for w: 2 3 2 -1
Dot product: 10
Compute another dot product (y/n)? n
Here are some few reminders
1. You MUST dynamically allocate the vectors
2. Remember to delete the vectors at the end of each iteration
3. You may assume that all input is valid
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
