Count Number of Digits in a Given Number
C program to Count number of digits in a given number using while loop.
Example : pgm.c
#include<stdio.h> int main(){ int d=0,n; printf("\nEnter the Number : "); scanf("%d",&n); while(n!=0){ n=n/10; d++; } printf("\nNo of Digits : %d",d); return 0; }
Output:
Enter the Number : 852147
No of Digits : 6
No of Digits : 6