Write a program to count the number of digits in an integer
#include<stdio.h> void main() { int n,count=0; printf("Enter any number: "); scanf("%d",&n); while(n!=0) { n/=10; count++; } printf("The Total number of digits is %d",count); }
Output
Enter any number: 2342
The total number of digits is 4