C++ Check for Palindrome
This Code takes your input reverses it and decides if it's a Palindrome.
* Featured post submitted and created by Padmanabhan.
C++
#include <iostream>
#include<string.h>
using namespace std;
int main() {
char a[50],b[50];
int j=0,i;
//Enter a word
cin>>a;
i=strlen(a);
for(;i>0;i--)
{
b[j]=a[i-1];
j++;
}
b[j]='\0';
cout<<"\nThe reverse of the string:\n"<<b<<endl;
if(strcmp(a,b)==0)
cout<<"\nThe given word is PALINDROME";
else
cout<<"\nThe given word is not PALINDROME";
return 0;
}
Comments
Post a Comment