#include<stdio.h>
#include<conio.h>
int sum(int);
int main()
{
int n,s;
printf("Enter the number: ");
scanf("%d",&n);
s=sum(n);
printf("The sum of digits is %d",s);
return 0;
}
int sum(int n)
{
if(n<10)
return n;
else
return (n%10+sum(n/10));
}
#include<conio.h>
int sum(int);
int main()
{
int n,s;
printf("Enter the number: ");
scanf("%d",&n);
s=sum(n);
printf("The sum of digits is %d",s);
return 0;
}
int sum(int n)
{
if(n<10)
return n;
else
return (n%10+sum(n/10));
}
No comments:
Post a Comment
Convey your thoughts to authors.