Answer to Question #256672 in Python for Raju

Question #256672

Character Frequency


Write a program to compute the frequency of characters other than space.


Sample Input 1

Pop up

Sample Output 1

o: 1

p: 3

u: 1


1
Expert's answer
2021-10-26T01:03:18-0400
#include <stdio.h>

int main() {
  char *s;
  int count['z'+1];
  scanf("%s", &s);
  for (int i = 0; i < sizeof(s) / sizeof(char); i++) {
    count[s[i]]++;
  }
  for (int i = 'a'; i <= 'z'; i++) {
    if (count[i]) {
      printf("%c: %d\n", i, count[i]);
    }
  }
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS