Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Code in C++ please
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

a. Do team members trust each other?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago