import java.io.*;
class string46
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s,k="",p="";
int i,l,c=0,c1=0,j;
System.out.println("Enter the string : - ");
s=br.readLine();
s=s+" ";
l=s.length();
for(i=0;i<l;i++)
{
if(s.charAt(i)!=' ')
{
k=k+s.charAt(i);
}
else
{
for(j=k.length()-1;j>=0;j--)
{
p=p+k.charAt(j);
}
if(k.equals(p)==true)
{
c1++;
}
p="";
k="";
}
}
System.out.println("The number of palindrome words in the upper string are : - "+c1);
}
}
what else we have to do if we have to print the pallindromic words also
ReplyDelete