59. C Program To find Number of Digits in a Given Number.
How does this program work?
- This Program is used to find the number of digits in a given number .
- Here we used a simple while loop to get the required output.
Here is the code
#include <stdio.h>
int main(void)
{
int no;
int totalDigits = 0;
printf("Enter a number : \n");
scanf("%d",&no);
while(no!=0)
{
no = no/10;
totalDigits ++;
}
printf("Total digits in the number is %d\n",totalDigits);
return 0;
}