#include <iostream>
#include <vector>
#include <algorithm>
int main() {
// Step 1: Declare a vector of integers
std::vector<int> myVector = {10, 20, 30, 40, 50};
// Step 2: Define the value to be searched
int targetValue = 30;
// Step 3: Use std::find to search for the value in the vector
auto result = std::find(myVector.begin(), myVector.end(), targetValue);
// Step 4: Check if the value was found
if (result != myVector.end()) {
// Step 5: Calculate the index of the found element
int index = std::distance(myVector.begin(), result);
// Step 6: Print the index of the found element
std::cout << "Element found at index: " << index << std::endl;
} else {
// Step 7: Print a message indicating that the element was not found
std::cout << "Element not found in the vector." << std::endl;
}
return 0;
}