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 / alex r.
// without loop
// for digit in DEC
#include <stdio.h>
int sum(int digit)
{
if (digit%10 != digit)
return digit%10 + sum(digit/10);
return digit;
}
int main(void)
{
int digit = 25634;
printf("\nSum:%d", sum(digit));
return 0;
}
Is This Answer Correct ? | 15 Yes | 7 No |
Post New Answer View All Answers
How can I change the size of the dynamically allocated array?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
What is chain pointer in c?
What will be your course of action for a push operation?
How do you view the path?
Is it cc or c in a letter?
Why do we need arrays in c?
What header files do I need in order to define the standard library functions I use?
What is meant by inheritance?
how do you programme Carrier Sense Multiple Access
How can I read and write comma-delimited text?
What does %c mean in c?
What are derived data types in c?
Why do we need volatile in c?
Is it better to use malloc() or calloc()?