<code>#include <stdio.h>
int digits (int n);
int main ()
{ int c,d;
while((c = scanf("%d",&d))!=EOF)
{
printf("%d n",digits(d));
}
return 0 ;
}
int digits (int n)
{
int p ;
if (n<10)
{
p++ ;
return p;
}
else {
p++;
n/=10;
digits (n);
}
}
</code>
<code>#include <stdio.h>
int digits (int n);
int main ()
{ int c,d;
while((c = scanf("%d",&d))!=EOF)
{
printf("%d n",digits(d));
}
return 0 ;
}
int digits (int n)
{
int p ;
if (n<10)
{
p++ ;
return p;
}
else {
p++;
n/=10;
digits (n);
}
}
</code>
#include <stdio.h>
int digits (int n);
int main ()
{ int c,d;
while((c = scanf("%d",&d))!=EOF)
{
printf("%d n",digits(d));
}
return 0 ;
}
int digits (int n)
{
int p ;
if (n<10)
{
p++ ;
return p;
}
else {
p++;
n/=10;
digits (n);
}
}
i expected it to recursively increase p but it always returns 1 or some other number that is not intended what should I do to make it run correctly?
New contributor
yahia yahiaoui098 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.