#include<stdio.h>//header file
#include<conio.h>//header file
int s=0;
int sum(int);
void main() //starting of the main() function
{
int j,n; //declaration of the variables
clrscr();
printf("program for the addition of digits of a (+)ve no. by recursion");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter the no. whose digits are to be added");
scanf("%d",&n);//taking input from the user
j=sum(n);
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nthe result is:%d",j);//printing output
getch();
}
int sum(int k)
{
int r;
if(k>0)
{
r=k%10;
k=k/10;
s=s+r;
sum(k);
}
else
return(0);
return(s);
}