[Solved] Find if an element exists in C++ array [duplicate]


There is a standard function called std::find in the header <algorithm>:

#include <iostream>
#include <algorithm>

int main() {
    int myarray[6]{10, 4, 14, 84, 1, 3};

    if (std::find(std::begin(myarray), std::end(myarray), 1) != std::end(myarray))
        std::cout << "It exists";
    else
        std::cout << "It does not exist";
    return 0;
}

Ideone

solved Find if an element exists in C++ array [duplicate]