How to count number of palindromes in the sentence

gealon2024 Posts 7 Registration date Thursday October 3, 2013 Status Member Last seen April 30, 2014 - Oct 4, 2013 at 02:29 PM
 Blocked Profile - Oct 7, 2013 at 03:06 PM
hello everyone;

can anybody teach me how to make a program using c language that would count the number of palindromes in a sentences and display the palindromes disregarding special characters...

example: Enter your sentence: " Ana and hannah together with her dad went to the beach.

number of palindromes: 3 ana hannah dad

i really need help;

6 replies

Blocked Profile
Oct 4, 2013 at 02:58 PM
Well, lets break it down.

0. load all variables-IE (PALCOUNT=0; sentance=""; dim wordarray()
1.Trap whole sentence in a variable
2.Count the number of spaces in the sentence
(IE 10-one_two_three_four_five_six_seven_eight_nine_ten_eleven)
3. Make an array with 10+1 slots-populate each element in array as word - redim your array with the count [wordarray(11)].
4. Loop through array and get the word, making another variable for the current word being scoured.
5. Make a logical check with the most right character (last character), with the first.
6. If it passes that test, then check the rest of the characters to see if match working from outter chars into inner.
7. If it passes increment variable of PALCOUNT++;

I am certain that you have this wireframe built but are looking for the actual code. I like to guide and advise, attempting to encourage to do your own research for particulars. I am certain Buno can come up with the C code for this logic.