#include#include using namespace std; int main() { set myset {10, 20, 30, 40, 50}; set ::iterator it; it = myset.find(30); if (it != myset.end()) { cout << "Element found in set: " << *it << endl; } else { cout << "Element not found in set" << endl; } return 0; }
#includeIn this example, we create a set of characters and search for the element 'b' using the find() function. Since 'b' is not present in the set, the output will be "Element not found in set". The set container and its member functions are part of the C++ Standard Library, which is included in all major C++ compilers. Therefore, no separate package or library is required to use the set data structure and its member functions.#include using namespace std; int main() { set myset {'a', 'e', 'i', 'o', 'u'}; set ::iterator it; it = myset.find('b'); if (it != myset.end()) { cout << "Element found in set: " << *it << endl; } else { cout << "Element not found in set" << endl; } return 0; }