5 10 20 30 40 50 30
Found at index 2
void stl_q5_find_element() {
vector<int> numbers = {10, 20, 30, 40, 50};
int searchValue = 30;
auto it = find(numbers.begin(), numbers.end(), searchValue);
if(it != numbers.end()) {
int position = it - numbers.begin();
cout << "Element " << searchValue << " found at position " << position << endl;
} else {
cout << "Element not found" << endl;
}
}
void stl_q5_find_element() {
vector<int> numbers = {10, 20, 30, 40, 50};
int searchValue = 30;
auto it = find(numbers.begin(), numbers.end(), searchValue);
if(it != numbers.end()) {
int position = it - numbers.begin();
cout << "Element " << searchValue << " found at position " << position << endl;
} else {
cout << "Element not found" << endl;
}
}