fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. printf("Count = %d\n",countZeros(10100) );
  6. printf("Count = %d\n",countZeros(-10010) );
  7. return 0;
  8. }
  9.  
  10. int countZeros(int num)
  11. {
  12. // Final stop
  13. if (num == 0 )
  14. return 0;
  15.  
  16. // Recursion
  17. int count = countZeros(num / 10);
  18.  
  19. // Increase count if current unit is 0
  20. if (num % 10 == 0)
  21. count++;
  22.  
  23. return count;
  24. }
  25.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
Count = 3
Count = 3