write a program to sum of its digit with using control
structure or with out using loop. for ex: let the number is
25634 then answer will be=2+5+6+3+4=20
Answer Posted / lalabs
// assume that num is non-negative.
int sum_digits_recursive ( int num )
{
if ( num == 0 ) return 0;
return (num % 10 + sum_digits_recursive ( num / 10 ));
}
Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
Can we increase size of array in c?
How can I split up a string into whitespace-separated fields?
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
Write a program to implement queue.
Explain heap and queue.
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
how to find binary of number?
Write a program to print all permutations of a given string.
The file stdio.h, what does it contain?
What is nested structure with example?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What is the size of a union variable?
What is a class c rental property?
Difference between strcpy() and memcpy() function?