this isnt the entire program, just part the part im having trouble with , in which i try to search for the values from array2 in array1 and display the position. how do i send out the numbers from array2 into the other function?
int main()
{
const int SIZE=10;
int array1[SIZE];
const int SIZE2=5;
int array2[SIZE2];
int z=function2(array1,SIZE,?);
}
int function2(int a[], int b, int c)
#include <iostream>
usingnamespace std;
int read(int arr[], int size, int x)
{
return arr[size-1]*x;
}
int main()
{
int ar[] = {3,4,5,6};
int size = 4;
int n = read(ar, 4, 100);
cout << n; // 600
return 0;
}
im not sure if you understand my question correctly or if i just dont understand your response.
if were like this
1 2 3 4 5 6 7 8 9
int main()
{
constint size=10;
int array[size];
int z=function2(array,size,29); // instead of 29, i need to send the numbers from another array
}
int function2(int a[],int b,int c) // this part needs to stay like this
#include <iostream>
usingnamespace std;
int read(int arr[], int size, int x)
{
return arr[size-1]*x;
}
int main()
{
int ar[] = {3,4,5,6};
int size = 4;
int anotherArray[] = {12,25,16,18,20};
int n = read(ar, 4, anotherArray[1] ); // send 2nd element of anotherArray
cout << n; // 150
return 0;
}
what do you mean its messed up, my program is more in-depth, im just posting the part i dont understand . this assignment is about the linear search algorithm using two different arrays.
sorry about the title, changed it
haha wow i did not type that well, i meant search for the values from array2 in array1 and display the position int n = read(ar, 4, anotherArray[1] ); // send 2nd element of anotherArray
^this is what you posted, instead of sending just one element, how do you send all of them