← All examples

do / while

C++ Loops

post-condition loop

Flowchart (ISO 5807)

NoYesStartInput nc = 0c++n /= 10n <= 0Return cEndFigure 1 — countDigits

Source code

int countDigits(int n) {
    int c = 0;
    do {
        c++;
        n /= 10;
    } while (n > 0);
    return c;
}