STRING PALINDROME OR NOT IN C++
#include <iostream>
#include <string.h>
using namespace std;
int main ()
{
char s1 [1000];
char s2 [1000];
cout<<"PLEASE ENTER A STRING : ";
cin>>s1;
strcpy(s2,s1);
strrev(s2);
if(strcmp(s1,s2)== 0)
{
cout<<s1<<" IS A PALINDROME"<<endl;
}
else
{
cout<<s1<<" IS NOT A PALINDROME"<<endl;
}
return 0;
}
#include <string.h>
using namespace std;
int main ()
{
char s1 [1000];
char s2 [1000];
cout<<"PLEASE ENTER A STRING : ";
cin>>s1;
strcpy(s2,s1);
strrev(s2);
if(strcmp(s1,s2)== 0)
{
cout<<s1<<" IS A PALINDROME"<<endl;
}
else
{
cout<<s1<<" IS NOT A PALINDROME"<<endl;
}
return 0;
}
OUTPUT
No comments