Thread: To check the String is palindrome or not.?

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    8

    To check the String is palindrome or not.?

    In C programming how can we check that the entered String is palindrome or not..?






  2. #2
    Registered User
    Join Date
    Sep 2012
    Posts
    357
    Basically, just check if the 0th (first) letter is equal to the last,
    the 1st (second) equal to the one before last
    ...
    the nth equal to the (last-n)th
    ...
    until you've checked all of them (except maybe a single middle letter for strings with odd length).

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    8
    firstly tell me how can i entered string..??

  4. #4
    Registered User
    Join Date
    Sep 2012
    Posts
    357
    Quote Originally Posted by sash.arya View Post
    firstly tell me how can i entered string..??
    Wasn't that lesson #2 (lesson #1 being the famous "Hello, World!" program)?
    Did you miss the class, maybe ...

    Check the fgets() function. It is a safe way to get strings.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  6. #6
    Registered User
    Join Date
    Oct 2012
    Posts
    8
    thnx...

  7. #7
    Registered User
    Join Date
    Oct 2012
    Posts
    8
    tell me the logic please...

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    qny described the logic in post #2.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to check for palindrome
    By Kristyy_mariee in forum C++ Programming
    Replies: 2
    Last Post: 03-03-2012, 07:08 PM
  2. Check to check string for a series of characters
    By robi in forum C Programming
    Replies: 1
    Last Post: 02-28-2012, 05:42 PM
  3. Replies: 10
    Last Post: 12-09-2011, 02:52 AM
  4. Recursively Checking a Palindrome string
    By TheUmer in forum C Programming
    Replies: 19
    Last Post: 12-04-2009, 07:38 PM
  5. Error in Recursive String Palindrome Code
    By clegs in forum C Programming
    Replies: 13
    Last Post: 12-21-2008, 12:36 PM

Tags for this Thread