title: How to calculate frequency of characters in a string
body: <p>I am a beginner with C programming so my code is very basic. It is to count the frequency of characters in a string. The program does run but the problem is that it displays each character as many times as it appears in the string. So, when I enter hello, I get "h occurs 1 times, e occurs 1 times, l occurs 2 times, l occurs 2 times, o occurs 1 times". How do i eliminate this and make the count for l appear only once? </p>
  
  <pre><code>for(i=0;str[i]!='\0';i++)
  {
    for(j=0;str[j]!='\0';j++)
          {
              if(str[i]==str[j])
                      count[i]++;
          }
  }
  for(i=0;i&lt;str[i]!='\0';i++)
      printf("%c occurs %d times \n",str[i],count[i]);
  </code></pre>