CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* Enter a number from <climits>
* LLONG_MIN -9223372036854775808
* to <climits> LLONG_MAX 9223372036854775807.
*
* Enter a zero based index for
* the digit you wish to find.
*
* An index that is out of range
* will throw an out_of_range exception.
*
* The integer value of the digit at the
* specified index for the given number is returned.
*/
#include <iostream>
#include <stdexcept>
#include <sstream>
#include <cstdlib>
using namespace std;
int getNumberOfDigits(long long number) {
int length = 1;
while((number /= 10) != 0){
++length;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run