Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A palindrome is a word or phrase that is the same forwards and backwards. For ex

ID: 3633307 • Letter: A

Question

A palindrome is a word or phrase that is the same forwards and backwards. For example
the word "radar" is a palindrome. Write a program that reads in a word from the keyboard
and determines if the word is a palindrome. The program does not need to determine if
the characters entered are actually a word. The word will be terminated by the value ".".
The "." is not part of the word and should not be looked at when determining the
palindrome. You should ignore case when comparing letters. The characters should be
read into a character array. The maximum word length is 20. Your program must use a
function called pal that takes a char array and an int size as parameters. The function
will return an int value of 1 if the array contains a palindrome and it will return a value
of 0 if it is not a palindrome. Your program should include a loop that lets the user repeat the palindrome determination until the user says she or he is done.

Explanation / Answer

please rate - thanks

#include<iostream>
using namespace std;
int pal( char[],int );
int main()
{char input[20];
int palin;
int i;
char yes;
do
{
i=0;
cout<<"Enter a word terminated with a .: ";
cin>>input;
while(input[i]!='.')
        i++;
       
palin=pal(input,i);
if(palin==1)
   cout<<input<<" is a Palindrome ";
else
    cout<<input<<" is not a Palindrome ";
cout<<"do it again?(y/n) ";
cin>>yes;
}while(toupper(yes)=='Y');
return 0;
}
int pal( char input[],int n)
{int i=0;
int j=n-1;
while(toupper(input[i])==toupper(input[j])&&i<=j)
      {i++;
       j--;
       }
if(i>j)
    return 1;
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote