
I have a syntax error with my
Here's the instructions for my C++ program:
Instructions
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
Here's what I have so far:
#include <iostream>
#include <string.h>
using namespace std;
//My user defined function that checks whether given string is palindrome
bool isPalindrome(string str)
{
//Finding the string length
int length = str.length();
//Iterating over string
for (int i = 0; i < length / 2; i++)
{
//Converting both characters into lower-case and then comparing them,
//So now, the comparison function will ignore the case
if (tolower(str[i]) != tolower(str[length - 1 - i])) {
return false;
}
}
//String is a palindrome
return true;
}
//Define the main function
int main()
{
//Array of strings
string s[7] = {"Madam", "22", "abBa", "67876", "444244", "trYmeuemyRT"};
/st/.isPalindrome("Madam") #=> #<MatchData "st">
/st/.isPalindrome("22") #=> #<MatchData "st">
/st/.isPalindrome("abBa") #=> #<MatchData "st">
/st/.isPalindrome("67876") #=> #<MatchData "st">
/st/.isPalindrome("444244") #=> #<MatchData "st">
/st/.isPalindrome("trYmeuemyRT") #<MatcData "st">
int i;
//Checking five strings
for (i = 0; i < 6; i++)
{
//Testing the boolean isPalindrome user defined function against the string variables.
if (isPalindrome(s[i]))
{
cout << "\n " << s[i] << " is a palindrome";
}
else
{
cout << "\n " << s[i] << " is not a palindrome";
}
}
return 0;
}
As you can see from my code, I've added 6 lines of regexp code that satisfies my lab environment's requirements. But it has to be placed in a different location in my program so it can execute properly. I'm unsure where to place them. Can someone help me?

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images

- C++ Need help with the functions While testing I am not getting the count for the vowles and consontants. Please jelp and test each option. Write a function that accepts a C-string as its argument. The function should count the number of vowels appearing in the string and return that number. Write another function that accepts a C-string as its argument. This function should count the number of consonants appearing in the string and return that number.Demonstrate the two functions in a program that performs the following steps:1. The user is asked to enter a string.2. The program displays the following menu: A) Count the number of vowels in the string B) Count the number of consonants in the string C) Count both the vowels and consonants in the string D) Enter another string E) Exit the program3. The program performs the operation selected by the user and repeats until the user selects E, to exit the program. // Sharissa Sullivan //Febuary 2 2023// Chapter 10 Vowels and…arrow_forwardC++ Programming D.S. Malik: AcctNumsIn.txt has been provided and contains a list of at least 15 six-digit account numbers. Implement the ValidateCheckDigits program to read in each account number and display whether it is valid. An account number is valid only if the last digit is equal to the remainder when the sum of the first five digits is divided by 10. For example, the number 223355 is valid because the sum of the first five digits is 15, the remainder when 15 is divided by 10 is 5, and the last digit is 5. Write only valid account numbers to an output file (AcctNumsOut.txt), each on its own line.arrow_forwardThanks for the help, but I'm not finished yet. Here are my instructions for my C++ program: 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 loopreturn true;}// isPalindrome Your program should print a message indicating if a string is a palindrome: madam is a palindrome Here's what I have so far: //Include the neccessary header files.#include <iostream>#include <string.h>#include <algorithm> //Declare the…arrow_forward
- Here are my instructions for my C++ program: Write a program that uses thefunction isPalindrome given inExample 6-6 (Palindrome). Testyour program on the followingstrings:madam, abba, 22, 67876, 444244, trymeuemyrt Modify the function isPalindromeof Example 6-6 so that whendetermining whether a string is apalindrome, cases are ignored, thatis, uppercase and lowercase lettersare considered the same. The isPalindrome function fromExample 6-6 has been includedbelow 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 loopreturn true;}// isPalindrome Your program should print amessage indicating if a string is apalindrome: madam is a palindrome The lab values require that I have the following string patterns in my lab: .+*isPalindrome\(\"Madam\"\).+* .+*isPalindrome\(\"abBa\"\).+* .+*isPalindrome\(\"22\"\).+* .+*isPalindrome\(\"67876\"\).+*…arrow_forwardin C++ solve the following question in the picture :arrow_forwardWhat is a semantic tableau and what is an advantage of using it to determine if a formula is satisfiable?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





