Advertisement
totobac

Untitled

Dec 28th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <cstring>
  4. using namespace std;
  5. const int MAX_SIZE = 100;
  6.  
  7. int numberOfDigits(char string[], int &counter, int size, int i)
  8. {
  9.     if (string[i] >= '0' && string[i] <= '9')
  10.         counter++;
  11.  
  12.     if (i == size)
  13.         return counter;
  14.  
  15.     i++;
  16.     numberOfDigits(string, counter, size, i);
  17.    
  18. }
  19.  
  20. int main()
  21. {
  22.     int counter = 0;
  23.     char string[MAX_SIZE];
  24.     cout << "Enter the string: " << endl;
  25.     cin >> string;
  26.     int size = strlen(string);
  27.  
  28.     cout << numberOfDigits(string, counter, size, 0);
  29.  
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement