Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program which takes as input two arrays from the user and performs element wise multiplication of the two arrays following which it

image text in transcribed
Write a C++ program which takes as input two arrays from the user and performs element wise multiplication of the two arrays following which it would display the resultant array. Both arrays will have the same number of elements. Your program should ask the user for the length of the arrays, and then populate both arrays by further querying the user for input. This assignment explores operations with partially filled arrays. Your program should declare arrays with a maximum size of 20. The user can choose the length of arrays from size 1 up to 20 elements. For Arrays A =[Ax, Ay, Az] and B =[B, By, B.] of length 3, the resultant array C =[Ax*Bx, Ay*By, A,*B] For example, your program will first ask for the number of elements N in the arrays. If the user provided N = 4, your program would take 4 numbers as input for the FIRST array, followed by 4 numbers for the SECOND array. Here, we are working with arrays with 4 numbers each. Let's say the user gave the following values for each array: FIRST array = 2, 4, 6, 8], SECOND array = [11, 12, 13, 17) Your program should compute the element wise multiplication of both arrays and display the resultant array. RESULT array would be computed as [2*11, 4*12, 6*13,8*17] = 122, 48, 78, 136], where: 1. The first elements from both arrays (2 and 11) are multiplied and the result (22) is stored in the first location of the RESULT array. RESULT array = 122, 2. The second elements (4 and 12) would be multiplied and the result (48) is stored in the second location of the RESULT array. RESULT array = 122, 48, 3. The third elements (6 and 13) are multiplied and the result (78) is stored in the third location of the RESULT array. RESULT array = 122, 48, 78, 4. Finally, the fourth elements (8 and 17) are multiplied and the result (136) is stored in the fourth location of the RESULT array. RESULT array = 122, 48, 78, 136 Once the RESULT array is computed, your program will then display this resultant array to the user. The same procedure applies for arrays of larger sizes. Your program will allow arrays with a maximum length of 20. Make sure your code works for any input number, not just the test cases. Your code will be tested on other test cases not listed here. Make sure your output matches the formatting as shown in the test cases below. Please properly comment your code before submission

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

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions