Showing posts with label Palindrome using pointer. Show all posts
Showing posts with label Palindrome using pointer. Show all posts

Palindrome using pointer

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
    int c=0,d;
    char str[30];char *a,*b;
    clrscr();
    printf("Enter the string:");
       scanf("%s",str);
    a=str;
    for(a=str; *a!='\0';a++);
    --a; 
    for(b=str; *b==*a; b++)
    {
       c=c+1;
       --a;
    }
    d=strlen(str);
    if(c==d)
             printf("\nGiven String is Palindrome");
    else
             printf("\nGiven string is not palindrome");

    getch();
}


Sample Output:

Programs and Solutions