Write a function isPalindrome (and the main() function to test it) that takes as input a word
and returns true if the word is a palindrome or false otherwise. The function receives the
word from the main() function, which will prompt the user whether the input word is
palindrome or not. for example abcba is a palindrome.
Also, please suggest to me another way to write this program.
code:
#include<iostream>
#include<cstring>
using namespace std;
char text[100];
int flag = 1;
int length;
void isPalindrome(char *text, int size);
int main()
{
cout<<"Enter a word: ";
cin.get(text,100);
return 0;
}
void isPalindrome(char *text, int size)
{for(length=0; text[length]!='\0'; length++)
{if(text[i]!=text[j])
{flag=0;
break;
}
} if (flag)
cout<<"The input word is Palindrome."<<endl;
else
cout<<"The input word is not palindrome."<<endl;
}