/*********************************************************************** The function in(char c, string s) returns true if c is in s and false otherwise ***********************************************************************/ #include #include using namespace std; bool in(char c, string s); int main() { char c; string s; cout << "Enter a character: "; cin >>c; cout << "Enter a string: "; cin >> s; if (in(c, s)) { cout << "The character " << c << " is in the string " << s << endl; } else { cout << "The character " << c << " is NOT in the string " << s << endl; } return 0; } // check whether c is in s bool in(char c, string s) { for(int i = 0; i < s.length(); i++) { if(c == s[i]) { return true; } } return false; }