You never change i inside the loop, so it loops forever with i==0. To fix it, add i++; at line 25. Better yet, use a for loop:
1 2 3 4 5
for (int i = 0; i < LEN; ++i) {
if (arr[i]==key ){
cout << "We got key into array arr.\n";
}
}
Or best of all, use a range-based for loop:
1 2 3 4 5
for (int val : arr) {
if (val == key) {
cout << "We got key into array arr.\n";
}
}
Note that all of these solutions will keep looking for a match, even after they find one. To stop looking after finding the first match, add break; right after the cout statement.