Advertisement
ghorardim

Habibur18

Sep 10th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. int t,i,len,count,j;
  6. char str[10001],ch[2],ce;
  7. scanf("%d",&t);
  8. for(j=1; j<=t; j++)
  9. {
  10. scanf(" %[^\n]",str);
  11. len=strlen(str);
  12. scanf("%s",ch);
  13. if(ch[0]>='A' && ch[0]<='Z') ce=ch[0]+' ';
  14. else ce=ch[0];
  15. count=0;
  16. for(i=0; i<len; i++)
  17. {
  18. if(ce==str[i] || ce==(str[i]+' ')) count++;
  19. }
  20. if(count>0)
  21. {
  22. printf("Occurrence of '%c' in '%s' = %d\n",ch[0],str,count);
  23. }
  24. else
  25. {
  26. printf("'%c' is not present\n",ch[0]);
  27. }
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement