Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <cctype>
- bool isPalindrome(const std::string& str) {
- std::string reversed = str;
- std::reverse(reversed.begin(), reversed.end());
- return str == reversed;
- }
- int countCharacters(const std::string& str) {
- return str.length();
- }
- std::string toUpperCase(const std::string& str) {
- std::string result = str;
- for (char& ch : result) {
- ch = std::toupper(ch);
- }
- return result;
- }
- void printResults(bool isPal, int count, const std::string& upperStr) {
- std::cout << "Is palindrome: " << (isPal ? "Yes" : "No") << "\n";
- std::cout << "Character count: " << count << "\n";
- std::cout << "Uppercase: " << upperStr << "\n";
- }
- int main() {
- std::string text = "level";
- bool isPal = isPalindrome(text);
- int count = countCharacters(text);
- std::string upperStr = toUpperCase(text);
- printResults(isPal, count, upperStr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement