Given a string as an input parameter, write a function bool isPalin(string) that returns true if the string is a palindrome, else returns false. Test the isPalin function using the string "Kanak" in the main function. Code in Ct+.
Added by Kristi T.
Step 1
Define the function isPalin with a string parameter. Show more…
Show all steps
Your feedback will help us improve your experience
Tanvi Garg and 89 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a function named palindrome_word(). It takes in a string as the only parameter. It returns True if the string is a palindrome by words. Otherwise, it returns False. A sample run of one possible implementation is shown below.
Alexandra D.
Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your program on the following strings: madam, abba, 22, 67876, 444244, trymeuemyrt Modify the function isPalindrome of Example 6-6 so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. The isPalindrome function from Example 6-6 has been included below for your convenience. bool isPalindrome(string str) {int length = str.length(); for (int i = 0; i < length / 2; i++) { if (str[i] != str[length – 1 – i]) { return false; } // if } // for loop return true;}// isPalindrome Your program should print a message indicating if a string is a palindrome: madam is a palindrome
Supreeta N.
Title: Palindrome Checker Program in C++ Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your program on the following strings: madam, abba, 22, 67876, 444244, trymeuemyrt. Modify the function isPalindrome of Example 6-6 so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. The isPalindrome function from Example 6-6 has been included below for your convenience. bool isPalindrome(string str) { int length = str.length(); for (int i = 0; i < length / 2; i++) { if (tolower(str[i]) != tolower(str[length - 1 - i])) { return false; } } return true; } Your program should print a message indicating if a string is a palindrome: madam is a palindrome abba is a palindrome 22 is a palindrome 67876 is a palindrome 444244 is not a palindrome trymeuemyrt is a palindrome #include <iostream> using namespace std; int main() { // Write your main here return 0; }
Akash M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD