class Frequency
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s;
char ch ;
System.out.println("Enter a String ");
s=br.readLine();
for(int i=0;i
int c=0;
ch=s.charAt(i);
for(int j=0;j
if(s.charAt(j)==ch)
c++;
}
System.out.println(ch + " has " + c + " frequency ");
}
}
}
2 comments:
if i enter a word hello,
the program will print l 2 times. The program should print should have a list of letters present in the word(without repetitions) and the corresponding frequency
Very informative article.Thank you author for posting this kind of article .
http://www.wikitechy.com/view-article/c-program-to-find-frequency-of-characters-in-a-string-with-example-and-explanation
Both are really good,
Cheers,
Venkat
Post a Comment