Number of Digits in a Number in C

Number of digits in a number in c programming language. Using this program we can count the number of digits in a number in c programming language.

Pre Increment and Post Increment in C

The value is incremented by one before being assigned to the variable with pre-increment. After assigning a value to a variable, the value is incremented using the post-increment method. ++ I’m going to increase the value of I and then return the new value. i++ will increase the value of I but it will also return the value that I had before it was incremented.

While Loop in C Program

In C programming, the while loop is the most fundamental loop. The while loop has only one control condition and runs as long as it is true. An entry-controlled loop is one in which the loop’s condition is evaluated before the loop’s body is run.

#include <stdio.h>
int main() 
{
long long n;
int count = 0;
printf("Enter the number");
scanf("%lld", &n);
do 
{
n /= 10;
++count;
}
while (n != 0);
printf("Number of digits%d", count);
}

Output:

Enter the number 4566
Number of digits 4