Suppose array1 is {1, 2, 3, 4, 5} and array2 is {2, 4, 8, 9, 10}. Show the accumulate, adjacent_difference, and partial_sum for array1. What is the inner product of array1 and array2? C++ language please
Code:-
#include<bits/stdc++.h>
using namespace std;
int main()
{ int sum = 0;//for
int array1[] = {1,2,3,4,5};//array1
int array2[] = {2,4,8,9,10};//array2
cout<<"Accumulate:
"<<accumulate(array1,array1+5,sum)<<endl;//It returns
the sum of all elements of array from 0th index to 4th index
int r[5];
partial_sum(array1,array1+5,r);//it returns the array of sum at
each index from starting index
cout<<"The partial sum is: ";//sum from staring index to
particular index
for(int i=0;i<5 ;i++)
cout<<r[i]<<" ";//display the returned array
cout<<endl;
int d[5];
adjacent_difference(array1,array1+5,d);//It returns the array of
adjacent difference between elements of array
cout<<"The adjacent difference is: ";
for(int i=0;i<5 ;i++)
cout<<d[i]<<" ";
cout<<endl;
int init = 0;//product between corresponding element and sum
them
//1x2+2x4+3x8+4x9+5x10
cout<<"Inner product:
"<<inner_product(array1,array1+5,array2,init);//It returns
the inner product of two vectors
return 0;
}

Output:-

if any doubt, ask in comments.
Suppose array1 is {1, 2, 3, 4, 5} and array2 is {2, 4, 8, 9, 10}....
Exercise 13.5 Write a Bash script that contains two numeric arrays, array1 and array2, initialized to the values in the sets {1, 2, 3, 4, 5} and {1, 4, 9, 16, 25}, respectively. The script should produce and display an array whose elements are the sum of the corresponding elements in the two arrays. Thus, the first element of the resultant array is 1 + 1 = 2, the second is 2 + 4 = 6, and so on.
Can someone explain what is happening in each line?: function HW1a($array1 ) { do { $sw = false; for( $i = 0, $c = count( $array1 ) - 1; $i < $c; $i++ ) { if( $array1[$i] > $array1[$i + 1] ) { list( $array1[$i + 1], $array1[$i] ) = array( $array1[$i], $array1[$i + 1] ); $sw = true; } } } while( $sw ); return $array1; } $array2 = array(3, 0, 2, 5, -1, 4, 1); echo "Original Array...
8 α = (д 1 9 2 5 3 4 5 10 3 6 7 86 9 10 2 7 10) 1 4 1 в = (1, 2 3 3 5 4 8 5 2 6 9 7 7 8 4 9 6 10 1 10) 10 8 ү 1 3 2 7 3 9 4 5 1 5 6 7 8 2 9 4 19) 10 1 ө ( 42 2 4 5 4 6 5 2 6 7...
(Print distinct numbers) C++ Write a program that reads in 10 numbers and displays distinct numbers (i.e., if a number appears multiple times, it is displayed only once). The numbers are displayed in the order of their input and separated by exactly one space. (Hint: Read a number and store it to an array if it is new. If the number is already in the array, discard it. After the input, the array contains the distinct numbers.) Sample Run Enter...
(1) Write the permutation 1 2 3 4 5 6 7 8 9 10 7 5 10 3 8 9 6 2 4 ( 10 1 as a product of disjoint cycles.
please answer all parts
10 9 8 7 6 5 4 3 2 1 9. I know which countries tend to cluster in similar sociocultural and economic groupi 10 9 8 7 6 5 4 3 2 1 2. I frequently attend seminars and lectures about other cultures or international topics. 10 9 8 7 6 5 4 3 2 1 3. I believe female expatriates can be equally as effective as male expatriates. 10. I feel capable of assessing...
C++ File I/O Create a program that will work for all "infile.txt" of similar structure: The first line will contain two integers. The first integer is the number of elements in array1, and the second integer the number of elements in array2. The second line will contain all the values of array1, and the third line will contain all values of array2. All numbers are separated by a space and all lines separated by a newline character. "infile.txt" has three...
Let U = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10), A = (1, 3, 5, 7, 9), 8 (2, 4, 6, 8, 10), and C (1, 2, 3, 4, 5, 10). List the elements of each set. (Enter your answers using roster notation. Enter EMPTY or for the empty set.) (a) 4 {2, 4, 6, 8, 10) (Đ) 1 0 0 {2,4, 10) X (1) cuc {}
Exercise for Section A 1. (10)3 +5)-? 3. (6-5+2)(5)-? 4.8+ (5(4)- 5. (10)(11)-1-? 6. 5+ 12/4-? 7. 10 + (2)(5)-5-? 8. 25-(92)+3-? 9. [(4 + 73- DI8-3]-? 10. [(3+5)+ (DX2)12- 11. The result of multiplication is known as the C. sum. 12. The result of addition is known as the C. sum. A. product. B. quotient. D. difference. A. product. B. quotient. 13. (4 +6(11)-? 14. (7-1+2)(4)-? 15. 20/(5 +5)-? 16. 9 +8/2-? 17. (12)(12)-3- 18. 9+ (4x8)-? 19. 15/3...
1 4 7 10 2 5 8 11 3 6 9 12 I want to print this matrix in c language. How did this formula come out? (3 * j + i + 1); #include <stdio.h> int main() { int y[3][4]; int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) printf("%d ", 3 * j + i + 1); printf("\n"); } return 0; }