Advertisement
Tahamina_Taha

counting number of digits in a integer

Aug 19th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. //counting number of a digits in a integer
  4. int n,count =0;
  5.     printf("enter a number: \n");
  6.     scanf("%d",&n);
  7.  
  8.     while(n!=0){
  9.         n=n/10;
  10.         ++count;
  11.     }
  12.     printf("total number of digits: %d",count);
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement