Number of digits before the decimal point in the division of two numbers | C ++ implementation of the approach ; Function to return the number of digits before the decimal in a / b ; Return the required count of digits ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countDigits ( int a , int b ) { return floor ( log10 ( abs ( a ) ) - log10 ( abs ( b ) ) ) + 1 ; } int main ( ) { int a = 100 ; int b = 10 ; cout << countDigits ( a , b ) ; return 0 ; }