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
Is c high or low level?
What is methods in c?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
What are pointers? What are different types of pointers?
What is the difference between void main and main in c?
What is a memory leak? How to avoid it?
What is difference between structure and union with example?
What is p in text message?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
Explain the difference between #include "..." And #include <...> In c?
given post order,in order construct the corresponding binary tree
Tell me when would you use a pointer to a function?
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
What is a c token and types of c tokens?
Can you please explain the difference between exit() and _exit() function?