Palindrome using pointer

Q. write a program to accept a string and find out whether it is palindrome or not  using pointer.

Ans.

/*program to check whether a string is palindrome or not using pointer*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char str[30];
 char *p,*t;
 printf("Enter any string : ");
 gets(str);
 for(p=str ; *p!=NULL ; p++);
  for(t=str, p-- ; p>=t; )
  {
    if(*p==*t)
    {
        p--;
        t++;
    }
    else
        break;
  }
  if(t>p)
       printf("\nString is palindrome");
  else
       printf("\n
String is Not palindrome");
  getch();
  return 0;
}



/*************Output*************/

Enter any string : SHAREMARKET
String is not palindrome


Enter any string :MADAM
String is palindrome


/*********Output as snap shot*********/

Out of checking whether a string is palindrome or not using pointer C program
Screen shot for checking whether a string is
palindrome or not using pointer

You might also like : 
  1. What is Palindrome
  2. Check palindrome using function

Comments