Function to find addition of digits of five digit number using recursion.

 #include <stdio.h>


int convert(int a)

{

    int value, num, n=0, j=10, i;

    

       if(a==0)

         return n;

       else

       { value=a;

        value=value%10;

        num=value;

        n=num+convert(a/10);

       

       }

         

}


int main()

{

    int a, sum;

   

    

    printf("Enter the 5 Digit number\n");

    scanf("%d", &a);

    

    sum=convert(a);

    

    printf("The sum of number is \n %d", sum);

   

    return 0;

}


Comments