Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



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

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 09-12-2008
Member
 
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.

Reply With Quote
  #2  
Old 09-12-2008
Member
 
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?
Reply With Quote
  #3  
Old 09-12-2008
Member
 
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?
Reply With Quote
  #4  
Old 09-12-2008
Member
 
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!
Reply With Quote
  #5  
Old 09-12-2008
Member
 
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:

Quote:
The sentence is not a palindrome
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Program to determine a word or a phrase is a palindrome in C/C++"
Thread Thread Starter Forum Replies Last Post
How to extract a word from phrase from Excel columns Kumar esan MS Office Support 5 24-02-2012 05:17 PM
How do I search files containing “a word or phrase in the file” in windows 7 Mewad Operating Systems 4 18-01-2011 09:46 AM
C# program for palindrome Smita.bendal Software Development 5 22-12-2009 03:07 PM
how to write program on palindrome in java? Linoo Software Development 3 26-11-2009 05:19 PM
C++ program to display ASCII code of a word or phrase Sonic Software Development 2 12-11-2008 01:09 PM


All times are GMT +5.5. The time now is 08:24 AM.