Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<ctype.h>
  4.  
  5. int main() {
  6. // Here 129 means 128 characters are allocated to memory.
  7. char text[129];
  8. // The character you want to find.
  9. char find;
  10. int i = 0, count = 0;;
  11.  
  12. printf("Enter Text: ");
  13.  
  14. // %[^\n]%s is used to take input till you press Enter
  15. scanf("%[^\n]%*c", text);
  16.  
  17. printf("Enter Character To Find: ");
  18. scanf("%c", &find);
  19.  
  20. for(i = 0; i < strlen(text); i++){
  21.  
  22. // Check Each Character
  23. if(tolower(text[i]) == tolower(find)){
  24. count++;
  25. }
  26.  
  27. }
  28.  
  29. printf("Frequency: %d", count);
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement