Question: C++ Test for palindrome I have to make a program telling me whether the string is palindrome or not. #include #include #include using namespace std;

C++ Test for palindrome

I have to make a program telling me whether the string is palindrome or not.

#include #include #include using namespace std;

void main() { char str[80], i; while(1) { cout << "Enter a string : "; cin >> str; if(strcmp(str, "END") == 0)break; for(i = 0; i < strlen(str); i++) { if(!(((str[i] >= 'a') && (str[i] <= 'z')) || ((str[i] >= 'A') && (str[i] <= 'Z')))) break; } if(i != strlen(str)) { cout << "this is not a palindrome" << endl; for(i = 0; i < 80; i++)str[i] = NULL; continue; } for(i = 0; i < (strlen(str) / 2); i++) { if(str[i] != str[strlen(str) - i - 1])break; } if(i == (strlen(str) / 2))cout << "this is a palindrome." << endl; else cout << "this is not palindrome." << endl; for(i = 0; i < 80; i++)str[i] = NULL; } }

this is my code but I have a problem. The problem is i need to make this work even if the word is uppercase or lowercase. but it only works when it matches.

how can i solve it?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!