Ticker

6/recent/ticker-posts

C programming, Calculate the total count of digits in a whole number.



#include <stdio.h>
int main() {
  long long n;
  int count = 0;
  printf("Enter an integer: ");
  scanf("%lld", &n); 
  do {
    n /= 10;
    ++count;
  } while (n != 0);
  printf("Number of digits: %d", count);
}