Question: How would you write this only using c-string and not to write this program on Linux? The goal of the program is to: Write a
How would you write this only using c-string and not
The goal of the program is to: Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.
#include
#include
#include
using namespace std;
int main() {
string userInput, reversed, modified;
char ch;
getline(cin, userInput);
for (int i = 0; i < userInput.size(); ++i) {
ch = tolower(userInput[i]);
if (isalnum(ch)) {
modified += ch;
reversed = ch + reversed;
}
}
if (reversed == modified)
cout << userInput << " is a palindrome" << endl;
else
cout << userInput << " is not a palindrome" << endl;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
