SHARE
TWEET

Untitled

a guest Oct 17th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top