To find the total number of digits in a number, consider number as a variable called num.

1. divide the num with 10.

2. store the result again in num, and increment the count value to 1.

3. step 1 and 2 repeats until num becomes 0.

4. exit loop and print count value as result.

#include<stdio.h>  
int main()
{
    int num,count=0;
    printf("Enter a number: ");
    scanf("%d",&num);
    while(num)
    {
        num=num/10;
        count++;
    }
    printf("Total number of digits in a given number: %d",count);
    return 0;
} 

C Program to Find Sum of Individual Digits of a Positive Integer Number has similar logic, but in every step we perform the sum of digits.

OUTPUT:

Enter a number: 4658
Total number of digits in a given number: 4