Write a program to check if a string (input by the user) is palindrome or not. A palindrome string is the one that reads the same if you read from backward or from forward, like madam, radar, civic, anna, bob, refers, and so on.
Sample Input:
none
Sample Output:
Not a palindrome
Sample Input:
civic
Sample Output:
word is palindrome
#include <iostream>
using namespace std;
void Palindrome()
{
string str;
cin >> str;
bool flage = true;
for (int i = 0; i < str.length(); i++)
{
if (str[i] != str[str.length()-i-1])
{
flage = false;
}
}
if (flage)
{
cout << "word is palindrome";
}
else
{
cout << "Not a palindrome";
}
}
int main()
{
Palindrome();
return 0;
}