#include<stdio.h>
#include<conio.h>
int fun(int num)
{ int rem,sum;
if(num==0)
return 0;
else
{ rem=num%10;
sum=rem+fun(num/=10); }
return sum;
}
void main()
{ int n,sod;
clrscr();
printf("Enter Number: ");
scanf("%d",&n);
sod=fun(n);
printf("Sum Of Digits Is: %d",sod);
getch();
}
that's really gud.
ReplyDeletefor simple program to find sum of digits of a number visit
http://codingloverlavi.blogspot.in/2013/05/sum-of-digits-of-number.html