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 to write this program on Linux?

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

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!