Find Sum of Digits of a Number using Recursion
C Programming Language Recursion in c (Article) Recursion in c (Program)
578Program:
#include int funSum(int x); int main(){ int num = 123; int f; f = funSum(num); printf("sum of %d and %d ",num,f); return 0; } int funSum(int x){ int a; int y = 0; if(x<=0){ return 0; } else{ a = x%10; x = x/10; y = a + funSum(x); return y; } }
Output:
sum of 123 and 6
Explanation:
None
This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.