0 votes 0 votes Write a complete ANSI C code using recursion to calculate the $sum(s)$ of the digits of an integer number (i) consisting of maximum 5 digits. For example, (1) = if $i=12345$, then your program should print $s=15$, (2) if $ i=457$, then $s=16$. Programming in C isi2017-pcb-cs programming programming-in-c descriptive + – go_editor asked Sep 20, 2018 • recategorized Apr 8, 2019 by akash.dinkar12 go_editor 407 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 2 votes 2 votes int calculateSum(int n) { if (n == 0) { return 0; } return (n%10) + calculateSum(n/10); } !KARAN answered Oct 5, 2019 • selected Dec 13, 2019 by Arjun !KARAN comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes int sum(int n){ if(n<=9) return n ; return n%10 + sum(n/10); } s_dr_13 answered Apr 7, 2022 s_dr_13 comment Share Follow See all 0 reply Please log in or register to add a comment.