Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago