Description:
Count the number of digits in an integer.
Count the number of digits in an integer.
C Code
#include <stdio.h>
int main() {
int n = 123456789, count = 0;
while (n != 0) { n /= 10; count++; }
printf("Digit count: %d\n", count);
return 0;
}
Expected Output
Digit count: 9