You don't state what is wrong; however, your for-loop in isPalindrome() should encase the five or so lines below its start. And please use the code tags, which are found under Format.
bool isPalindrome (string str)
{
int i;
int length = str.length();
for (i = 0; i < length; ++i)
if (str.at(i) != str.at(length - i - 1)) returnfalse;
returntrue;
}
You might want to google to learn more about how this algorithm works
#include <iostream>
#include <string>
bool isPalindrome(const std::string );
int main()
{
std::string str;
std::cout << "Enter word: ";
std::cin >> str;
if ( isPalindrome(str) )
std::cout<<"The word is a palindrome.\n";
else
std::cout<<"The word is not a palindrome.\n";
return 0;
}
??? isPalindrome (???)
{
int ??? = ???;
for ( int i = 0; i < length / ???; i++)
{
if ( ??? != ??? )
return ???;
}
return ???;
}