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
List the difference between a 'copy constructor' and a 'assignment operator' in C?
Tell me what is null pointer in c?
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only
What is a dynamic array in c?
What is a macro?
what are enumerations in C
What is modifier & how many types of modifiers available in c?
How do you do dynamic memory allocation in C applications?
When should structures be passed by values or by references?
What is c system32 taskhostw exe?
How do you list files in a directory?
How can I find the modification date and time of a file?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
Can we change the value of #define in c?
How can I remove the leading spaces from a string?