Using Do While loop

I am using a do while loop in a program that checks if a sentence is a palindrome. The program works fine when compressing the sentence and reversing it, but does pick up if the compressed word and the reversed is the same. and when user enters y to restart loop it enters the same sentence as the first time. I'm no sure where to place my statements.

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
// Declarations: Declaring variables
string sentence, choice, reversed, lower_sentence, compressed;
int numletters, i;
char letter;

do
{
cout << "Enter a sentence to check: " << endl;
getline(cin, sentence);


numletters = sentence.length();

for (i=0; i<= numletters; i++)
{
letter = tolower(sentence[i]);
if (letter != ' ')
{
lower_sentence = lower_sentence + letter;
}
}
compressed = lower_sentence;
compressed.length();

for (i=0; i<=numletters; i++)
{
letter = tolower(sentence[i]);
if (letter != ' ')
{
reversed = letter + reversed;
}
}


cout << "Compressed: " << compressed << endl;
cout << "Reversed: " << reversed << endl;
if (reversed == compressed)
{
cout << "===>Palindrome!!!" << endl;
}

cout << "Do you want to enter another? [Y or N]" << endl;
cin>> choice;
} while (choice == "Y" || choice == "y");
system ("pause");
return 0;
}
Please stop making multiple posts about issues regarding the same program:

http://www.cplusplus.com/forum/beginner/114220/
http://www.cplusplus.com/forum/beginner/114217/

You should be able to make one clear and concise post about your entire program.
this is the issue I am having now
Topic archived. No new replies allowed.