find element in vector

#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    std::vector<int> myVector = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int targetValue = 6;

    // Step 1: Use the find algorithm from the <algorithm> header to search for the target element
    auto it = std::find(myVector.begin(), myVector.end(), targetValue);

    // Step 2: Check if the element was found
    if (it != myVector.end()) {
        // Step 3: Calculate the index of the found element using std::distance
        int index = std::distance(myVector.begin(), it);

        // Step 4: Print the index of the found element
        std::cout << "Element found at index: " << index << std::endl;
    } else {
        // Step 5: Print a message if the element was not found
        std::cout << "Element not found in the vector." << std::endl;
    }

    return 0;
}