#include #include #include using namespace std; void main() { string s; cout << "Enter string:" << endl; cin >> s; // dereference return value from min_element. Note that string is a C++ container of chars, so it has iterators. cout << *min_element(s.begin(), s.end()) << " is a minimal character in the string." << endl; // same procedure for max_element cout << *max_element(s.begin(), s.end()) << " is a maximal character in the string." << endl; }