Check out example codes for "how to find how many digits a number has in c++". It will help you in understanding the concepts better.

Code Example 1

#include <iostream>
#include <cmath>

unsigned int getNumberOfDigits (int i)
{
    return i > 0 ? log10((double) i) + 1 : 1;
}

int main()
{
	std::cout << "Number of digits: " << getNumberOfDigits(/*Example*/6738) << std::endl;  
	return 0;
}

Learn ReactJs, React Native from akashmittal.com