Digit count in given no


Write a C Program to count the number of digits in a given number.

						
#include  <stdio.h>
#include  <conio.h>

void main()
{
  int  n , d=0 , r , temp ;

  printf("Enter a number: ") ;
  scanf("%d" , &n) ;   
  
  if(n==0)  /* Special Case */
    printf("Number of digits in 0 is 1") ;
  else
  {
    temp=n ;
    while(n!=0)
    {
      ++d ;       /* Counting */
      n=n/10 ;  /* Reduce number by 1 digit */
    }
    printf("Number of digits in %d is %d" , temp , d) ;
  } 
}


Output :

Output