Count the number of digits in a number with C.
#include <stdio.h>
int main()
{
long long num;
int count = 0;
/* Input number from user */
printf("Enter any number: ");
scanf("%lld", &num);
while (num != 0){
num /= 10;
count++;
}
printf("Total digits: %d", count);
return 0;
}
Output:-
Enter any number : 564465
Total digits : 6
0 Comments