Find number of digits in a Number

Find number of digits in a Number

#include
int main()
{
int n,count=0;
printf(“Enter an integer: “);
scanf(“%d”, &n);
while(n!=0)
{
n/=10; /* n=n/10 */
++count;
}
printf(“Number of digits: %d”,count);
}

Leave a Reply

Your email address will not be published. Required fields are marked *