Mahmud33

count number of digits in a number

Jun 30th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.19 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4.  
  5. {
  6.  
  7.     int i,n,c=0;
  8.  
  9.     scanf("%d",&n);
  10.  
  11.     while(n != 0){
  12.  
  13.         n/=10;
  14.         c++;
  15.  
  16.     }
  17.  
  18.     printf("%d\n",c);
  19.  
  20.     return 0;
  21.  
  22. }
Add Comment
Please, Sign In to add comment