1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help on palendromes

Discussion in 'C' started by bothie, Nov 25, 2006.

  1. bothie

    bothie New Member

    Joined:
    Nov 14, 2006
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    Harare,Zimbabwe
    can you assist me with a c++ code that will verify whether an input word or sentence is a PALENDROME.Detailing it as much as you could
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Here is the C program to check whether a string is palindrome or not.

    Code:
    #include<stdio.h>
     #include<string.h>
     #define size 26 // u can set the maximum allowable size of the string here
     
     void main()
     {
         char strsrc[size];
         char strtmp[size];
     
         clrscr();
         printf("\n Enter String: "); 
         gets(strsrc);
     
         strcpy(strtmp,strsrc); // create a copy
         strrev(strtmp); // reverse the copied string
     
         if(strcmp(strsrc,strtmp)==0) // compare the two strings
             printf("\n Entered string \"%s\" is palindrome",strsrc);
         else
             printf("\n Entered string \"%s\" is not    palindrome",strsrc);
     
         getch();
     } 
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    Just an offtopic comment
    [comment]Its palindrome and not palendrome.[/comment]
     
  4. bothie

    bothie New Member

    Joined:
    Nov 14, 2006
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    Harare,Zimbabwe
    thanx ,for the correction ,does the 'strrev' function exists in c++
     

Share This Page