Code Competitions

Coding competition
Showing posts with label check string is palindrome or not. Show all posts
Showing posts with label check string is palindrome or not. Show all posts

Tuesday, 4 June 2013

program to check string is palindrome or not

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
    void read(char *);
    void p_drom(char *);
    void compare(char *,char *);
    char *p,*p1,*p2,*p3;
    clrscr();
    p=p2;
    p1=p3;
    cout<<"enter the string ";
    read(p);
    strcpy(p1,p);
    puts(p1);
    p_drom(p);
    //puts(p);
    compare(p,p1);
    getch();
}
void read(char *p)
{
    gets(p);
}
void p_drom(char *p)
{
    strrev(p);
    puts(p);
}
void compare(char *p,char *p1)
{
       //    char *p2,*p3;
    int a;
    a=strcmp(p,p1);
    if(a==0)
    {
        cout<<"the string is palindrome";
    }
    else
    {
        cout<<"the string is not palindrome";
    }
}