Write a program to check whether the given string is palindrome or not using pointer to arrays (Pointer Arithmetic).

/* Write a program to check whether the given string is palindrome or not

using pointer to arrays (Pointer Arithmetic).*/

#include <stdio.h>

void main()

{

    char st[20],*f,*r;

    printf("Enter a string : ");

    gets(st);

    f=r=st;

    while(*r)

        r++;

    r--;

    printf("The given string is ");

    while (f<r)

    {

        if(*f!=*r)

        {

            printf("Not ");

            break;

        }

        f++;

        r--;

    }

    printf("A Palindrome\n");

    getch();

}

Comments

Popular posts from this blog

Write a program to accept numerator and denominator and find the remainder without using modulus (%) operator using do..while loop.