Advertisement
Guest User

Wrong

a guest
Apr 8th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 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.         gets(sentence);
  15.         scanf("%c", &x);
  16.  
  17.         int len = strlen(sentence);
  18.  
  19.         for(j = 0; j < len; j++)
  20.         {
  21.             if (sentence[j] == x)
  22.             {
  23.                 n++;
  24.             }
  25.         }
  26.  
  27.  
  28.     if(n==0)
  29.         printf("'%c' is not present\n", x);
  30.     else
  31.         printf("Occurrence of '%c' in '%s' = %d\n", x, sentence, n);
  32.     }
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement