Program:
#include <stdio.h>
int digit_sum(int n){
int d=0;
if(n==0)
return 0;
else
d=n%10;
return d+digit_sum(n=n/10);
}
int main(){
int n;
printf("Enter the Number: ");
scanf("%d",&n);
printf("\n\t-->> Sum Of the Digit of %d is %d . \n",n,digit_sum(n));
}
Expected O/P:
Enter the Number: 4563
-->> Sum Of the Digit of 4563 is 18 .
0 Comments
Post a Comment