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
What is nested structure?
Can I initialize unions?
Here is a neat trick for checking whether two strings are equal
What is the difference between class and object in c?
Which node is more powerful and can handle local information processing or graphics processing?
What is a far pointer in c?
What is meant by int main ()?
What are the advantages of using macro in c language?
Which type of language is c?
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
Describe the order of precedence with regards to operators in C.
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
What are lookup tables in c?
what is event driven software and what is procedural driven software?