Program to count digits in an integer

Count the number of digits in a long integer entered by a user.

 

 

int countDigit(long long n) 
{ 
    int count = 0; 
    while (n != 0) { 
        n = n / 10; 
        ++count; 
    } 
    return count; 
} 

 

posted @ 2020-05-01 20:18  Jasper2003  阅读(109)  评论(0编辑  收藏  举报