C Program To Find The Sum of Digits of An Integer Using Recursion

#include<stdio.h>
#include<conio.h>

int sumdigits(int n)
{
if(n==0)
return 0;

return ((n%10)+sumdigits(n/10));

}

void main()
{
int num;
clrscr();
printf("Enter any Number  :  ");
scanf("%d",&num);

printf("Sum is  :  %d",sumdigits(num));

getch();

}
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment