## C Program To Find Sum of Digits of Number using Recursion

Learn How To Calculate Sum of Digits of Number using Recursion in C Programming Language. It is important that we should know **How A For Loop Works** before getting further with the C Program Code. You can simply Enter a Number and Print its Sum of Digits.

#### Example

**Sum of Numbers/Digits of 1234 = 10**

**Also Read: C Program To Find Sum of Digits of a Number using For Loop**

#### C Program To Find Sum of Digits of Number using Recursion

#include<stdio.h> int sum(int x); int main() { int res, num; printf("\nEnter a Number:\t"); scanf("%d", &num); res = sum(num); printf("\nSum of Digits : \t%d\n", res); return 0; } int sum(int x) { if(x == 0) { return x; } else { return (x%10 + sum(x/10)); } }

**Also Read: C Program To Find Factorial of Number using Recursion**

#### Output

**Also Read: C Program To Print Fibonacci Series using Recursion**

If you have any compilation error or doubts in this C Program To Calculate Sum of Digits of a Number using Recursion, let us know about it in the Comment Section below.

Best explanation for Recursion I found on the net.

Ohh… Thanks Ram Kumar. I know recursion is a little difficult to understand but not impossible. It takes time, practice and hardwork to understand recursion properly.