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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started