Program to find the total number of palindrome in a given string

Here is  the program to find the total number of palindromes present in the entered sentence.  This program internally uses the logic to find the palindrome, discussed earlier.

Logic :  The given string is traced word-by-word till the EOL. To trace the words, it uses the logic of earlier program, where we counted the number of words. Each time, Each time, when we find the full word, we pass the ord to the internal block which checks if the word is a palindrome or not, the logic discussed earlier.

int stpal(char str[50], int st, int ed);
void main()
char str[50];
int pal = 0, len = 0, i, start = 0, end;
printf(“\n\n\t ENTER A SENTENCE…: “);
if((str[i] == ‘ ‘ && str[i+1] != ‘ ‘) || i == len)
if(i == len)
end = i;
end = i – 1;
if( stpal (str, start, end ) )
start = end + 2;
printf(“\n\n\t THE TOTAL NUMBER OF PALINDROMES ARE..: %d”,pal);
int stpal(char str[50], int st, int ed)
int i, pal=0;
for(i=0; i<=(ed-st)/2; i++)
if(str[st+i] == str[ed-i])
pal = 1;
pal = 0;
return pal;
Download exe and source code here.

Editorial Team
Editorial Team

We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.

3 thoughts on “Program to find the total number of palindrome in a given string

  1. pls any one can write a program to below given situation”
    Display count of words in the given Text.
     Display count of characters in the given Text.
     Display repeated words with repetition count.
     Display any palindrome words found in the text.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.