问答题

根据题目要求,在空白处填写补全代码。
#include
 
int digit_sum(int num);
 
int main(int argc, char* argv[]) {
  int n1, sum;
printf(" Recursion : Find the sum of digits of a number :");
printf("-----------------------------------------------------");   
  printf(" Input any number to find sum of digits: ");
  scanf("%d", &n1);
   
  sum = digit_sum(n1);//call the function for calculation
   
  printf(" The Sum of digits of %d = %d", n1, sum);
   
  return 0;
}
int digit_sum(int n1) {
  if(n1 == 0)
    return 0;
return ( 1 ) // do not forget the comma
     
}

答案: ((n1 % 10) + digit_sum(n1 / 10));或(n1 % 10) + digit_sum(n1 /...
微信扫码免费搜题