1.

Write a program to input a string and check whether it is palindrome or not using character pointer.

Answer»

#include <iostream>

using namespace std;

int main()

{

char *str="";

int len,i,j,flag=0;

cout<<"Enter a string";

cin>>str;

for(i=0;*(str+i)!="\0;i++);

len=i;

for(i=0;j=len-1;i<len/2;i++;j--)

{

if(*(str+i)!=*(str+j))

{

flag=1;

break;

}

}

if(flag==1)

cout<<*It is not palindrome";

else

cout<<"It is palindrome";

}



Discussion

No Comment Found