Given Sentence Palindrome or Not

Discussion in 'C' started by realtime.funda, May 23, 2010.

  1. realtime.funda

    realtime.funda New Member

    Joined:
    May 23, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi there...

    Please send me Accurate C++ code to reverse the sentence and find the given sentence is palidrome or not.

    Thanx in advance...
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    This is a really easy task and if you cannot do it yourself then you should ask why you are on a programming course in the first place.

    Here's a major hint. Look at the string "Hello olleH". What do you notice about characters [0] and [strlen-1]? What do you notice about [1] and [strlen-2]? And in general [n] and [strlen-1-n]? HINT HINT HINT ***for loop***. You can do it in about 6 lines of code, and you don't need to reverse the string to be able to tell if it's a palindrome.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice