Results 1 to 5 of 5

Thread: Program to determine a word or a phrase is a palindrome in C/C++

  1. #1
    Join Date
    Feb 2008
    Posts
    1,337

    Program to determine a word or a phrase is a palindrome in C/C++

    I am preparing a code for a user described word or a phrase to be accepted and then specify that whether the code is palindrome or not. I some one can give me some basic idea about it then it would be great? Hope to here from you very sooner.

  2. #2
    Join Date
    May 2008
    Posts
    3,971

    Re: Program to determine a word or a phrase is a palindrome in C/C++

    Ideally you can do coding for the word but for the phrase, it is not at all possible. As you might be knowing that phrase will include "spaces". So how will keep track of those spaces?

  3. #3
    Join Date
    Feb 2008
    Posts
    1,337

    Re: Program to determine a word or a phrase is a palindrome in C/C++

    Actually, my principle is that my program removes spaces of the sentence or when the program faces a space and it will increase to next character. So in that way the spaces would not be a problem in our code, right?

  4. #4
    Join Date
    May 2008
    Posts
    3,971

    Re: Program to determine a word or a phrase is a palindrome in C/C++

    In my opinion the biggest problem is not space but the storage of phrases that you must perform before!

  5. #5
    Join Date
    May 2008
    Posts
    945

    Re: Program to determine a word or a phrase is a palindrome in C/C++

    See the below code:

    Code:
    # include <stdio.h> 
    # include <string.h> 
    
    char sentence [50] = "Johnson and Johnson"; 
    char temp [50]; 
    int i; 
    int LEN; 
    
    for (i = 0; sentence! = "\ 0"; + + i) 
    + + LEN; 
    
    for (i = 0; i <LEN; + + i) 
    temp = sentence [- LEN]; 
    
    if (strcmp (temp, sentence)) 
    printf ( "The sentence is a palindrome"); 
    else 
    printf ( "The sentence is not a palindrome");
    This should work and will give you the out as:

    The sentence is not a palindrome

Similar Threads

  1. How to extract a word from phrase from Excel columns
    By Kumar esan in forum MS Office Support
    Replies: 5
    Last Post: 24-02-2012, 05:17 PM
  2. Replies: 4
    Last Post: 18-01-2011, 09:46 AM
  3. C# program for palindrome
    By Smita.bendal in forum Software Development
    Replies: 5
    Last Post: 22-12-2009, 03:07 PM
  4. how to write program on palindrome in java?
    By Linoo in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 05:19 PM
  5. C++ program to display ASCII code of a word or phrase
    By Sonic in forum Software Development
    Replies: 2
    Last Post: 12-11-2008, 01:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,707,459.70074 seconds with 17 queries