Advertisement
Guest User

Correct

a guest
Apr 8th, 2020
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.     int i, j, t;
  7.     char sentence[10000];
  8.     char x;
  9.     scanf("%d", &t);
  10.     for(i = 1; i <= t; i++)
  11.     {
  12.         int n = 0;
  13.  
  14.         getchar();
  15.         gets(sentence);
  16.         scanf("%c", &x);
  17.  
  18.         int len = strlen(sentence);
  19.  
  20.         for(j = 0; j < len; j++)
  21.         {
  22.             if (sentence[j] == x)
  23.             {
  24.                 n++;
  25.             }
  26.         }
  27.  
  28.  
  29.     if(n==0)
  30.         printf("'%c' is not present\n", x);
  31.     else
  32.         printf("Occurrence of '%c' in '%s' = %d\n", x, sentence, n);
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement