CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Counting Digits by Dividing

C code walkthrough · Question 49
mediumLoops

Code

Read carefully. What does this print?
1#include <stdio.h>
2 
3int main() {
4 int n = 12345, count = 0;
5 while (n > 0) {
6 n /= 10;
7 count++;
8 }
9 printf("%d\n", count);
10 return 0;
11}

Your answer