Question: I have to create a C++ program that enters a string and checks if it is a palindrome, the strings that were identified as palindromes

I have to create a C++ program that enters a string and checks if it is a palindrome, the strings that were identified as palindromes have to be reversed. My code is attached below. Where am i going wrong and how can I fix it???

#include

#include

#include

using namespace std;

char checkPalin(char str[]);

int main()// use string

{

/* this part has

call to function

print statement

return statement

maximum of 5 lines!!!!!!!!*/

char str [100];

int length = checkPalin (str)

cout << "The Palindrome is: " << length << endl;

}

char checkPalin(char str [100])

{

int num;

cout << "Enter the number of strings: " <

cin >> num;

cout << "Enter the strings: " << endl;

cin.getline(str, 100);

int length;

for (length = 0; str[length] != '\0'; length++);

int i, j, palindrome = 1;

for (i = 0, j = 0; i < length/2; i++, j--)

{

if (str[i] != str[j])

{

palindrome = 0;

}

}

if (palindrome)

int length = strlen(str) - 1;

while (length = 0)

{

cout << str[length] <

length--;

}

return length;

}

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!