I have a syntax error with my program code. Can someone help me? 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 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 <iostream>#include <string.h> using namespace std; //My user defined function that checks whether given string is palindromebool isPalindrome(string str){//Finding the string lengthint length = str.length(); //Iterating over stringfor (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 caseif (tolower(str[i]) != tolower(str[length - 1 - i])) {return false;}}//String is a palindromereturn true;} //Define the main functionint main(){//Array of stringsstring 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 stringsfor (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?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I have a syntax error with my program code. Can someone help me?

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?

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education