#include<stdio.h>int rem,sum;int calsum(int n){if(n!=0){ rem=n%10; sum=sum+rem; calsum(n/10);} return sum;}//------------------------------------------------intmain(){int num,val; clrscr();printf("\nEnter a number: ");scanf("%d",&num); val=calsum(num);printf("\nSum of the digits of %d is: %d",num,x);return0;}
Output :
Enter a number: 123 Sum of the digits of 123 is : 6
Incoming search terms:
- program to find sum of digits of a number in c using recursion (7)
- c program to find the sum of digits of a number using function (7)
- sum of digits using recursion in c (6)
- c program to calculate sum of digits using recursion (4)
- sum of digits using recursion (3)
- sum of digits of a number using recursion in c (3)