In this program, the user is ask to enter the number, then the number of digits the given number have will be displayed on console.
#include<stdio.h>
#include<conio.h>
void main()
{
int num, digit=0;
//clrscr();
printf("Enter a number: ");
scanf("%d", &num);
while(num!=0)
{
digit++;
num = num / 10;
}
printf("No. of digits = %d", digit);
getch();
}
Enter a number: 42513
No. of digits = 5
Enter a number: 47
No. of digits = 2