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.
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.
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?
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?
In my opinion the biggest problem is not space but the storage of phrases that you must perform before!
See the below code:
This should work and will give you the out as: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");
The sentence is not a palindrome
Bookmarks