How to count number of digits in a number in C

1 Answer

0 votes
#include <stdio.h>
#include <math.h>

int main(void) {
    int num = 18739;

    int len = log10(num) + 1;

    printf("%d", len);
}



/*
run:

5

*/

 



answered Jul 23, 2021 by avibootz

Related questions

1 answer 120 views
1 answer 102 views
1 answer 114 views
1 answer 174 views
1 answer 171 views
171 views asked Nov 14, 2016 by avibootz
1 answer 191 views
1 answer 97 views
...