C Program to Count Number of Digits of a Number (Integer)
belongs to collection: Loops C Programs for Practice
All Answers
need an explanation for this answer? contact us directly to get an explanation for this answer
#include<stdio.h>
int main()
{
int n,count=0;
printf("Enter Any Number To Count Digit : \n\n");
scanf("%d", &n);
while(n!=0)
{
n/=10;
++count;
}
printf("\nNumber of Digits Is = %d",count);
return 0;
}
Output:
Enter Any Number To Count Digit:
123456789
Number Of Digit Is =9
EE
need an explanation for this answer? contact us directly to get an explanation for this answertotal answers (2)
Output:
Enter Any Number To Count Digit :
12345
Number Of Digit Is =5
need an explanation for this answer? contact us directly to get an explanation for this answer