Results 1 to 3 of 3

Thread: How to check planidrome dynamically?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Expert Member
    Join Date
    Oct 2006
    Answers
    209

    How to check planidrome dynamically?

    Please tell about Writing a program how to check planidrome dynamically?

    Note : This is the question asked by a visitor Venkat. I am posting this in proper forum.


  2. #2
    Contributing Member
    Join Date
    Apr 2007
    Answers
    58

    Re: How to check planidrome dynamically?

    1) read string to an array variable.
    2) calculate the length of the string using proper string function!
    3) set two integer variables point to start & end of the string array!
    4) use a FOR loop to increment & decrement start and end variables respectively until start = end or start > end!
    5) compare both characters in each cycle and if not same it means the string is not palindrome.
    6) Print result!

    Now, try to code yourself....Anyway I'll help you...

    Regards,
    Anoop :)
    If its useful, dont forget to [COLOR="Red"]THANK[/COLOR] me :cool:

  3. #3
    Expert Member
    Join Date
    Mar 2012
    Answers
    208

    Re: How to check planidrome dynamically?

    Program to check for palindrome

    #include < stdio.h >
    #include < string.h >
    #include < stdlib.h >
    #include < ctype.h >

    int isPalindrome(char string[]);

    int main()
    {
    isPalindrome("avon sees nova");
    isPalindrome("a");
    isPalindrome("avon sies nova");
    isPalindrome("aa");
    isPalindrome("abc");
    isPalindrome("aba");
    isPalindrome("3a2");
    return(0);
    }

    int isPalindrome(char string[])
    {
    int count, countback, end, N;

    N = strlen(string);
    end = N-1;

    for((count=0, countback = end); count <= (end/2); ++count,--countback)
    {
    if(string[count]!=string[countback])
    {
    return(1);
    }
    }

    printf("\n[%s] is a palidrome!\n", string);
    return(0);
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact