CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List
C Code Walkthrough #49

Counting Digits by Dividing

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