invalid types 'int[int]' for array subscript
can someone help i can't figure out the probleam. you will understand what i am trying to do by these steps 1> take size of array as input 2>tale numbers of arrays 3>take int key as input 4>create a function then use a for loop to check if key and array a number is same. #include <iostream> int linear(int n , int arr , int key) { for (int i = 0; i < n; i++) { if (key==arr[i]) { std::cout <<i; } else{ return -1; } } } int main() { int n; std::cin>>n; int arr[n]; for (int i = 0;i<n;i++) { std::cin>>arr[i]; } int key ; std::cin >> key ; std::cout << linear(n , arr , key); return 0; } i am getting two errors 1> mention on question 2> invalid conversion from int to int .