Computer Science, asked by Nikunjgrg6360, 1 year ago

Write a C program to read an integer, find the sum of digits of a given integer using recursive function.

Answers

Answered by tamil98
2

int main()

{

int n,r;

printf("enter an integer");

scanf("%d",&n);

r=sum(n);

printf("the sum of digits %d",r);

getch();

return 0;

}

int sum(n)

{

if(n!=0)

{

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

}

else

{ return 0;

}

}

Similar questions