C Programming
Computer Programming

Program in c to Count Number of Digits of an Integer



Write a Program in c to Count Number of Digits of an Integer

\* C Program to to Count Number of Digits of an Integer *\

# include < stdio.h >
int   main( )
{

int   num, dig  ;
printf(" Enter the Number : ") ;
scanf("%d ", & num) ;
dig = 0 ;
do
{

num = num / 10 ;
dig = dig + 1 ;

}
while (   num   >   0 ) ;
printf(" \n Number of digit in Integer : ") ;
printf("%d ", dig) ;
return ( 0 ) ;

}

Output of Program :

Output of Program in C to Count Number of Digits of an Integer