...

View Full Version : having problems creating loop



Recklein3
09-30-2009, 08:31 PM
I am writing a program that will check whether or not specific text input is a palindrome or not.
I'm a little stuck trying to fit in my loop while checking the text.
Any help would be greatly appreciated.





#include<iostream>
#include<string>

using namespace std;

int main()
{
char strn[80];
cout<<"Please enter your text input: ";
cin.getline(strn,80);
int len=strlen(strn);
int loop=0;


bool palin=true;

for(int c=0;c!=len/2;c++)
{
if(palin)
{
if(strn[c]!=strn[len-c-1])
{
palin=false;
}

}
else
{
break;
}
}



if(palin)
{
cout<<"Your text input is a palindrome.";
}
else
{
cout<<"Your text input is not Palindrome.";
}

cin.get();
return 0;


}

BWiz
10-01-2009, 01:44 AM
Where exactly are you errors? Remember to consider your checking when you have an even amount of characters and an odd amount of characters.

Recklein3
10-01-2009, 02:34 AM
there is no errors
but i need to have the program loop over and over again in till you enter END to end the loop or in other words the string

abduraooft
10-01-2009, 03:18 PM
There was a similar thread at http://www.codingforums.com/showthread.php?t=177620 which might be helpful to you too.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum