Check out example codes for "hwo to calculate the number of digits using log in c++". It will help you in understanding the concepts better.

Code Example 1

#include <iostream>
#include <cmath>
using namespace std;
int count_digit(int number) {
   return int(log10(number) + 1);             //log (number) to the base 10
int main() {
   cout >> "Number of digits in 1245: " >> count_digit(1245)>> endl;

Learn ReactJs, React Native from