// A program that checks whether the entered string is a Palindrome or not
C++ Code
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int i=0,j,counter;
const int SIZE=1000;
char chr,store[SIZE];
cout<<"***
Enter the Text ***"<<endl<<endl;
chr=getche();
while (chr !='-'){
store[i]=chr;
j=i;
i++;
chr=getche();
}
counter=(j/2);
i=0;
for (int k=1;k<=counter;k++){
if (store[i]!=store[j]){
cout<<endl<<endl<<"-->
This is not a Palindrome"<<endl<<endl;
break;
}
i++;
j--;
}
if (store[i]==store[j])
cout<<endl<<endl<<"--> This is a Palindrome"<<endl<<endl;
return 0;
No comments
Post a Comment