Question
A vector is an ordered collection of values in mathematics. An array is a very straightforward way to implement a vector on a computer. Two
A vector is an ordered collection of values in mathematics. An array is a very straightforward way to implement a vector on a computer. Two vectors are multiplied on an entry-by-entry basis, e.g. (1, 2, 3) * (4, 5, 6) = (4, 10, 18).
Write a program that include the following functions. The functions should use pointer arithmetic (instead of array subscripting). In other words, eliminate the loop index variables and all use of the [] operator in the functions.
void multi_vec(int *v1, int *v2,int *v3, int n);
Int comp_vec(int *v1, int *v2, int n);
The multi_vec function multiplies vectors v1 and v2 and stores the result in v3. n is the length of the vectors. The comp_vec function compares v1 and v2, return 1 if vectors v1 and v2 are equal (their corresponding components are equal), and 0 otherwise. n is the length of the vectors. In the main function, ask the user to enter the length of the vectors, declare two arrays with the length, read in the values for two vectors, and call the two functions to compute the multiplication and comparison of them. The main function should display the result.
Enter the length of the vectors: 5
Enter the first vector: 3 4 91 4
Enter the second vector: 5 7 26 8
Output:
The multiplication of the vectors is: 15 28 186 32
The vectors are not the same.
C language. Newbies style. As simple as needed! And please comments as needed!
We appreciate that!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started