C Online Compiler
Example: C Program to Find Number of Digits in an Integer Value
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Find Number of Digits in an Integer Value #include <stdio.h> // It's the main function of the program int main() { long long number = 0; long long temp_num; int count = 0; // Step-1 Take input from the User printf("Enter an integer value: "); scanf("%lld", &number); temp_num = number; // Step-2 Iterate over the `number` variable using the while loop while (number != 0) { number /= 10; count++; // Increment count of the Number } // Step-3 Final output of the program printf("\nTotal %d digits in '%lld'\n", count, temp_num); return 0; }
55326
Output
Clear
ADVERTISEMENTS