Advertisement
Nabil-Ahmed

Untitled

Jul 25th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. //Frequency of characters//
  2. #include<stdio.h>
  3. int main()
  4. {
  5. char str[50],ch;
  6. int i, frequency=0;
  7. printf("Enter String : ");
  8. gets(str);
  9. printf("Search a Character : ");
  10. scanf("%c",&ch);
  11. for(i=0;str[i]!='\0';i++)
  12. {
  13. if(ch==str[i])
  14. frequency++ ;
  15. }
  16. printf("Yes!%c found %d times(s)",ch,frequency);
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement