for adding the digits in an number using recursion:
add_digit(int num)
{
static int s=0;
int d=0;
if (num!=0)
{
d=num%10; /// to get the unit digit
num=(num-d)/10;
s=s+d; // to sum the digit's
}
else
{
return(sum);
}
}
1 comment:
add details more elobrate
Post a Comment