// 10.15.1.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include #include using namespace std; bool isPalindrome(char str[50]); bool isAlphaStr(char str[50]); int countChar(char str[50], char c); int main() { char str[50]{}; char check; int count; cout << "Input a string: "; cin.getline(str, 50); cout << "Input a charcter to check: "; cin >> check; cout << "\n\n"; if (isPalindrome(str)) { cout << "\"" << str << "\" is a palindrome.\n"; } else { cout << "\"" << str << "\" is not a palindrome.\n"; } if (isAlphaStr(str)) { cout << "\"" << str << "\" only contains alpahbetic charcters.\n"; } else { cout << "\"" << str << "\" contains one or more non alphabetic charcters.\n"; } count = countChar(str, check); cout << "\"" << str << "\" contains " << count << " " << check << "'s."; } bool isPalindrome(char str[50]) { string s = str, p = s; reverse(p.begin(), p.end()); return s == p; } bool isAlphaStr(char str[50]) { int i = 0; while (str[i]) { if (!isalpha(str[i])) { return false; } i++; } return true; } int countChar(char str[50], char c) { int count = 0, i = 0; while (str[i]) { if (str[i] == c) { count++; } i++; } return count; }