Advertisement
afrinahoque

Count the number of digits in a number

Jun 11th, 2019
126
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. int main()
  3. {
  4.     int n, Count=0;
  5.     printf("Enter a number:");
  6.     scanf("%d",&n);
  7.     while(n!=0)
  8.     {
  9.         n=n/10;
  10.         Count=Count+1;
  11.     }
  12.     printf("Number of digits: %d",Count);
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement