July 23rd, 2003, 08:06 AM
I have a problem writing a program to check weather the string is palindrome, and to get the ASCII sum of the string.
Any suggestion? C++ Visual Basic
July 23rd, 2003, 08:28 AM
Well, I'd just use strlen to find the length of the string, set one counter as the length and the other as 0, and loop through checking if each character matches.
July 23rd, 2003, 09:20 AM
I think should do it.......
using namespace std;
int i, j;
bool isPalindrome = true;
cout << "Please enter a phrase to check: ";
for(i=0, j=phrase.length() - 1; i<j; i++, j--)
if(phrase[i] != phrase[j])
isPalindrome = false;
if(isPalindrome == true)
cout << "This Was A Palindrome" << endl;
cout << "This Was NOT A Palindrome" << endl;