1 You are given an integer N and integer array A as the input, where N denotes the length of A Write a program to find the product of every element with its next consecutive integer on the number line and return the sum of all these products. DS/Algo - 75 marks Example- Array=(1,2,3,5) Result= 1*2 + 2*3 + 3*4 + 5*6 = 2+6+12+30 = 50 1 Function description English Communication Complete the check function in the editor below. It has the following parameter(s): 1 2. 3 Name Type Description 4 5 6 INTEGER ARRAY Denotes different numbers as elements. 7 8 D 9 « 10 11 12 13 14 15 Return The function must return an INTEGER denoting the sum of the proc of all the elements with their next consecutive number
Answers
Answer:
1 You are given an integer N and integer array A as the input, where N denotes the length of A Write a program to find the product of every element with its next consecutive integer on the number line and return the sum of all these products. DS/Algo - 75 marks Example- Array=(1,2,3,5) Result= 1*2 + 2*3 + 3*4 + 5*6 = 2+6+12+30 = 50 1 Function description English Communication Complete the check function in the editor below. It has the following parameter(s): 1 2. 3 Name Type Description 4 5 6 INTEGER ARRAY Denotes different numbers as elements. 7 8 D 9 « 10 11 12 13 14 15 Return The function must return an INTEGER denoting the sum of the proc of all the elements with their next consecutive number
Answer:
#include <stdio.h>
const int ARRAY = 50
int product(int arr[ARRAY], int n)
{
int pro= 1;
for (int i = 0; i < n; i++)
pro = pro * arr[i];
return result;
}
int main()
{
int z;
scanf ("%d",&z);
int arr[] = { 17, 21, 32, 42, 85 };
printf("%d", product(arr, z));
return 0;
}
Explanation:
scanf("%d",&n); scans the scale of array.
int arr[] = ; initializes an Array containing five factors.
printf("%d", product(arr, n)); calls the function "product" and the function returns the end result and the printf feature prints it.
In the function "product" in the loop factors of array are expanded one at a time and the counter "i" is boom to transport forward.
The final product printed stored in "pro" is 40,783,680.
#SPJ3
25 MAY 2022