#include <stdio.h>
      int main() {
        long long n;
        int count = 0;
        printf("Enter an integer: ");
        scanf("%lld", &n);
        // iterate at least once, then until n becomes 0
        // remove last digit from n in each iteration
        // increase count by 1 in each iteration
        do {
          n /= 10;
          ++count;
        } while (n != 0);
        printf("Number of digits: %d", count);
      }
      
      C language logo

      Digits

      0

      0

      avatar
      natalie19970

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.