C Program to count the number of digits in the given number

#include<stdio.h>
int main()
{
    int num;
    printf("Enter the number\n");
    scanf("%d",&num);
    int count=0,rem,n=num;
    while(num!=0)
    {
        rem=num/10;
        count=count+1;
        num=num/10;
    }
    printf("\n the number of digits in %d is %d\n",n,count);
}

Output:


Comments