Samiul_Islam_Abir

002

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