i've wrote the code for finding the num of digits in the function Digits(num)
the function should return no of digit in the num, but the output of my coding doesn't runs well.instead od returning 5, it returns 4!
here's my code:
#include<stdio.h>
#include<conio.h>
int Digits(int num);
void main()
{
int num;
num = 12345;
clrscr();
printf("%d",Digits(num));
getch();
}
int Digits(int num)
{
int i;
if(num>i)
{
num = num / 10;
++i;
return i;
}
else
return i;
}