#include<stdio.h>
int sum(int);
main()
{
int n,c;
printf("Enter the no");
scanf("%d",&n);
c=sum(n);
printf("%d",c);
}
int sum(int n)
{
int r,d;
if(n==0)
return 0;
else
{
r=n%10;
d=r+sum(n/10);
return d;
}
}
ASSIGNMENT 8)
int sum(int);
main()
{
int n,c;
printf("Enter the no");
scanf("%d",&n);
c=sum(n);
printf("%d",c);
}
int sum(int n)
{
int r,d;
if(n==0)
return 0;
else
{
r=n%10;
d=r+sum(n/10);
return d;
}
}
ASSIGNMENT 8)
TO DEMONSTRATE RECURSION
No comments:
Post a Comment