Guest User

Untitled

a guest
Jan 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstring>
  3. using namespace std;
  4. int count(char str[], char ch)
  5. {
  6. int size;
  7. int i(0);
  8. int cnt;
  9. size = strlen(str);
  10. for(int i = 0; i<size; i++)
  11. {
  12. if(str[i] == ch)
  13. cnt++;
  14. }
  15. return cnt;
  16. }
  17.  
  18. int main()
  19. {
  20. char a[1000];
  21. char ch;
  22. int cnt ;
  23. cin >> a;
  24. cout << "Enter the serching charactor";
  25. cin >> ch;
  26. cnt = count(&a[0], ch);
  27. cout << cnt <<'\n';
  28. }
Add Comment
Please, Sign In to add comment