Are you trying to calculate the sum of the digits in
num
recursively?
If that is the case, something like this might work for you;
#include<stdio.h>
int dob(int num);
int calc(int num);
int main() {
int num, c;
printf("enter the number ");
scanf("%d", &num);
printf("the sum of the digits is %d", calc(num));
return 0;
}
int calc(int num) {
int sum = num;
do {
sum = dob(sum);
} while (sum > 9);
return sum;
}
int dob(int num) {
if (num < 10)
return num;
else
return dob(num / 10) + dob(num % 10);
}
Hope this helps,
Fredrik