Advertisement
SergeyPGUTI

8.1.10

Feb 14th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int count(char a[], char c)
  9. {
  10.     int counter=0;
  11.     int length=strlen(a);
  12.     for (int i=0;i<length;i++)
  13.     {
  14.         if (a[i]==c) counter++;
  15.     }
  16.     return counter;
  17. }
  18.  
  19. int main()
  20. {
  21.     char str[30]="Hello";
  22.     cout<<count(str,'e');
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement