This program is basically for count number of digits of an integer number. But when I give input digits without start with zero( '100' ) then it works fine but if I give input with starts zero( '00100' ) then it gives wrong output.
example:
1) input: 100
output: 3. it is expected output.
2) input: 00100
output: 2. it is an unexpected output.
because it takes '00100' integer number as an integer number '64' I don't know why?
#include <stdio.h>
#include <stdlib.h>
int Digit_count(int);
int main(void)
{
int a;
a = Digit_count(00100);
printf("\nNumber of Digits = %d\n",a);
return 0;
}
/// function for count number of digits
int Digit_count(int a)
{
int p,digit;
p=a,digit=0;
printf("\n%d\n",p); // **This line code prints Output: 64**
while(p!=0)
{
p = p/10;
digit++;
}
return digit;
}