text: Logarithm tricks for Competitive Programming | C implementation count the number of digits in a number ; Function to count the number of digits in a number ; Driver Code
code: #include <stdio.h> NEW_LINE #include <math.h> NEW_LINE int countDigit ( long long n ) { return ( floor ( log10 ( n ) + 1 ) ) ; } int main ( ) { double N = 80 ; printf ( " % d " , countDigit ( N ) ) ; return 0 ; }