#include
#include
using namespace std;
/*
* This interactive C++ program prints how many digits
* a number has.
*
* @creator gdt
* @created 02018.03.28
* @edu written during a csc100 class
*/
int main(int, char**) {
cout << "enter an integer: ";
int n;
cin >> n;
int ndigits = log10(n) + 1;
cout << n << " has " << ndigits << " digit(s)\n";
double x = log10(n) + 0.1;
ndigits = ceil(x);
cout << n << " has " << ndigits << " digit(s)\n";
ndigits = ceil(log10(n) + 0.1);
cout << n << " has " << ndigits << " digit(s)\n";
ndigits = log(n) + 1;
cout << "hmm..." << n << " has " << ndigits << " digit(s)\n";
}
/* the output that was printed when the program
* name log10 was executed six times...
$ log10
enter an integer: 8
8 has 1 digit(s)
8 has 1 digit(s)
8 has 1 digit(s)
$ log10
enter an integer: 37
37 has 2 digit(s)
37 has 2 digit(s)
37 has 2 digit(s)
$ log10
enter an integer: 128
128 has 3 digit(s)
128 has 3 digit(s)
128 has 3 digit(s)
$ log10
enter an integer: 1024
1024 has 4 digit(s)
1024 has 4 digit(s)
1024 has 4 digit(s)
$ log10
enter an integer: 32767
32767 has 5 digit(s)
32767 has 5 digit(s)
32767 has 5 digit(s)
$ log10
enter an integer: 1234567890
1234567890 has 10 digit(s)
1234567890 has 10 digit(s)
1234567890 has 10 digit(s)
hmm...1234567890 has 21 digit(s)
*/