Advertisement
mihainan

Lab4 PC - ex 3 (CA)

Oct 23rd, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int number_of_digits(int n)
  4. {
  5.     if(n == 0)
  6.         return 0;
  7.     else
  8.         return 1 + number_of_digits(n/10);
  9. }
  10.  
  11. int main()
  12. {
  13.     int x, nr;
  14.     scanf("%d ", &x);
  15.     nr = number_of_digits(x);
  16.     printf("%d\n", nr);
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement