Write a program to check whether the given string is palindrome or not using character arrays.

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

using character arrays.*/

#include <stdio.h>

void main()

{

    char st[20],rev[20];

    int i,j;

    printf("Enter a string : ");

    gets(st);

    for(i=0;st[i];i++);

    i--;

    for(j=0;i>=0;i--,j++)

    {

        rev[j]=st[i];

    }

    rev[j]=0;

    printf("The reverse is %s\n",rev);

    printf("The given string is ");

    for(i=0;st[i];i++)

    {

        if(st[i]!=rev[i])

        {

            printf("Not ");

            break;

        }

    }

    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.