143
Problem Count the digits of a number (1234 -> 4).

A do-while loop is used so that the number 0 is counted as 1 digit.

Solution 1: do-while loop C++ 9 lines
int main() {
    int num = 1234;
    int len = 0;
    do{
        num = num / 10;
        len++;
    }while(num != 0);
    cout << len;   // 4
}
Solution 2: String method C++ 3 lines
int num = 1234;
int len = to_string(num).length();
cout << len;